<template>
  <div class="page-container page-container-create">
    <!--setp##-&#45;&#45;111start-->
    <!-- 添加商品 -->
    <el-dialog :visible.sync="dialogVisibleTwo" title="添加商品" :close-on-click-modal="false">
      <div>
        <div>
          <el-form
            :model="productForm"
            :inline="true"
            ref="productForm"
            :size="size"
            :rules="productFormRules"
          >
            <div class="col-sm-9">
              <el-form-item label="商品名称：" prop="goodsName" class="w178 mb30" label-width="112px">
                <el-input clearable
                          v-model="productForm.goodsName"
                          auto-complete="off"
                          maxlength="80" placeholder="商品名称"
                ></el-input>
              </el-form-item>
              <el-form-item label="商品编码：" prop="thirdSpuId" class="w178">
                <el-input clearable
                          v-model="productForm.thirdSpuId"
                          auto-complete="off" maxlength="80" placeholder="商品编码"
                ></el-input>
              </el-form-item>
              <el-form-item label="商品分类：" prop="goodsCategory" class="w178">
                <el-input clearable
                          v-model="productForm.goodsCategory"
                          auto-complete="off" maxlength="80" placeholder="商品分类"
                ></el-input>
              </el-form-item>
              <el-form-item label="所属店铺名称：" prop="storeName" class="w178">
                <el-input v-model="productForm.storeName" auto-complete="off" clearable maxlength="80" placeholder="所属店铺名称"></el-input>
              </el-form-item>
            </div>
          </el-form>
          <el-row class="mb30 mt20 t_r">
            <el-button size="mini" type="primary" @click="resetProductForm()" class="resetButton" icon="el-icon-refresh"
            >重置</el-button
            >
            <el-button size="mini" @click="productFormFind()" icon="el-icon-search" class="searchButton"
            >搜索</el-button
            >
            
            <el-button size="mini" @click="addAllProduct()" class="searchButton"
            >全部添加</el-button
            >
          </el-row>
        </div>
        <div >
          <el-table
            :data="tableDataTwo"
            @selection-change="addSelectionChangeProduct"
            :header-cell-style="tableHeaderColor"
            ref="multipleTable"
            :row-class-name="tableRowClassName"
            :size="size"
          >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column
              prop="code"
              label="商品编码"
              sortable
              align="center"
              width="300"
            ></el-table-column>
            <el-table-column
              prop="chineseName"
              label="商品名称"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="goodsCategory"
              label="商品分类"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="storeName"
              label="所属店铺"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="salePriceScope"
              label="原价（元）"
              align="center"
            ></el-table-column>
          </el-table>
          <!--分页栏-->
          <div
            class="toolbar t_r"
            v-if="tableDataTwo.length > 0"
          >
            <el-pagination
              @size-change="producthandleSizeChange"
              @current-change="producthandleCurrentChange"
              :current-page="productForm.start"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="productForm.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="productListTotal"
            >
            </el-pagination>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" >
        <el-button :size="size" @click.native="dialogVisibleTwo = false" plain type="primary"
        class="cancelButton"
        >取消</el-button
        >
        <el-button
          :size="size"
          type="primary"
          @click.native="dialogVisibleTwo = false"
          @click="productTableData2Click"
          :loading="productEditLoading"
          class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>
    <!--setp##-&#45;&#45;111end-->
    <!--审核弹框-->
    <el-dialog
      title="管理员备注"
      class="el-dialog-style"
      :visible.sync="dialogVisibleAdmin"
      :close-on-click-modal="false"
      @closed="handleClose"
    >
      <el-form
        :model="adminDataForm"
        label-width="100%"
        :size="size"
        ref="adminDataForm"
        :rules="adminDataFormRules"
        label-position="right"
        inline
      >
        <el-form-item prop="auditRemark" class="textarea">
          <el-input clearable
                    type="textarea"
                    placeholder="请输入备注"
                    v-model="adminDataForm.auditRemark"
                    :rows="4">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button
          :size="size"
          @click.native="submitFormAdminNotPass"
          type="primary" plain
          class="cancelButton"
        >不通过</el-button
        >
        <el-button :size="size" type="primary" @click.native="submitFormAdmin"
        class="searchButton"
        >通过</el-button
        >
      </div>
    </el-dialog>

    <!--面包屑导航-->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>营销中心</el-breadcrumb-item>
        <el-breadcrumb-item>其他类促销</el-breadcrumb-item>
        <el-breadcrumb-item> 换购活动</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!--页面标题-->
    <p class="font22 mb20">创建换购促销</p>
    <!--工具栏-->
    <div class="toolbar">
      <!--步骤条-->
      <div class="stepset" >
        <ul>
          <li :class="{'active':active>=1}"><span>1</span><p>设置促销规则</p></li>
          <li :class="{'active':active>=2}"><span>2</span><p>设置活动商家/店铺</p></li>
          <li :class="{'active':active>=3}"><span>3</span><p>设置活动商品</p></li>
          <li :class="{'active':active>=4}"><span>4</span><p>创建成功</p></li>
        </ul>
      </div>
      <!-- 基本设置表单-->
      <div v-show="active == 1" class="content create_stepOne createSet">
        <el-form
          :inline="true"
          :model="filters"
          :rules="filtersRules"
          ref="filters"
          :label-position="labelPosition"
        >
          <div>
            <div class="title">
              基本设置：
            </div>
            <div class="item">
              <el-row class="m_b30">
                <el-form-item
                  label="活动名称："
                  prop="promName"
                  class="wid color999"
                >
                  <el-input clearable
                            type="text"
                            v-model.trim="filters.promName"
                            placeholder="请输入3-60个字符之间"
                            maxlength="60"
                            minlength="3"
                            class="input "
                  />
                </el-form-item>
              </el-row>
              <el-row class="m_b30">
                <el-form-item
                  label="活动时间："
                  prop="promotionStartEndTime"
                  class="wid w450"
                >
                  <div style="width:100%;">
                    <el-date-picker
                      v-model="filters.promotionStartEndTime"
                      type="datetimerange"
                      range-separator="至"
                      start-placeholder="开始时间"
                      end-placeholder="结束时间"
                      size="mini"
                      format="yyyy-MM-dd HH:mm:ss"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      :picker-options="timeCheck"
                    ></el-date-picker>
                  </div>
                </el-form-item>
              </el-row>
              <el-row class="pdL10  m_b30  activityTags">
                <el-form-item label="活动标签：" prop="labelId" class="wid">
                  <el-select
                    v-model="filters.labelId"
                    placeholder="请选择"
                    size="mini"
                    :required="true" clearable
                    class="width450"
                  >
                    <el-option
                      v-for="item in tagList"
                      :key="item.id"
                      :label="item.tagName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                  <el-button type="primary" size="mini" @click="addtags"
                  class="searchButton"
                  >添加标签</el-button
                  >
                </el-form-item>
              </el-row>
            </div>
          </div>

          <div class="w100">
            <div class="title">
              活动规则：
            </div>
            <div class="item">
              <el-row class="m_b30 labelAlignment">
                <el-form-item
                  label="活动类型："
                  prop="frontPromType"
                  class="wid"
                >
                  <el-radio-group v-model="filters.frontPromType" @change="resetPromotionRule(0)">
                    <el-radio
                      :label="15"
                      class="form-radio mr40 radioAlignment noMarginLeft" border
                    >满金额换购</el-radio
                    >
                    <el-radio :label="16" class="form-radio radioAlignment noMarginLeft" border
                    >买商品换购</el-radio
                    >
                  </el-radio-group>
                </el-form-item>
              </el-row>
              <el-row>
                <el-form-item
                  label="是否叠加应用"
                  prop="overlayAppFlag"
                  class="wid"
                  v-if="false"
                >
                  <div style="width:100%;">
                    <el-radio-group v-model="filters.overlayAppFlag">
                      <el-radio :label="0" class="form-radio w144 t_l noMarginLeft"
                      >否（超量：按最高层级享受优惠）</el-radio
                      >
                      <el-radio :label="1" class="form-radio w144 t_l noMarginLeft" @change="resetPromotionRule(1)"
                      >是（倍量：每满一级优惠一次）</el-radio
                      >
                    </el-radio-group>
                    <el-form-item
                      prop="overlayAppNum"
                      label=",上限"
                      class="wid"
                      v-if="filters.overlayAppFlag == 1"
                    >
                      <span v-if="filters.overlayAppFlag == 1"></span>
                      <el-input clearable
                                size="mini"
                                style="width:100px"
                                v-model="filters.overlayAppNum"
                                maxlength="3"
                      ></el-input>
                      <span>次</span>
                    </el-form-item>
                  </div>
                </el-form-item>
              </el-row>

              <el-row >
                <el-form-item label="优惠设置：" class="wid labelAlignment vt pdL10" prop="promotionRules">
                  <div class="disCountSet disCountSetTwo">
                    <el-table :data="filters.promotionRules"  class="stepOne_table specialTable">
                      <el-table-column prop="couponSetindex" label="优惠阶梯" width="100">
                        <template slot-scope="scope">
                          <label>{{ scope.$index + 1 }}</label>
                        </template>
                      </el-table-column>
                      <el-table-column prop="content" label="优惠门槛" width="308">
                        <template slot-scope="scope" class="conditionValue">
                          <div class="flex">
                            <el-form-item
                              :prop="'promotionRules.' + scope.$index + '.conditionValue'"
                              :rules="filtersRules.conditionValue"
                              class="errorInfoAlignment"
                            >
                              <span class="disCountSetLabel" v-if="filters.frontPromType==15">满</span>
                              <span class="disCountSetLabel" v-if="filters.frontPromType==16">买</span>
                              <el-input
                                v-model="scope.row.conditionValue"
                                placeholder="X"
                                :size="size"
                                clearable maxlength="10"
                              ></el-input>
                              <span class="disCountSetLabel" v-if="filters.frontPromType==15">元</span>
                              <span class="disCountSetLabel" v-if="filters.frontPromType==16">件</span>
                            </el-form-item>
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column prop="explain" label="优惠说明" width="180">
                        <template slot-scope="scope">
                          <label>
                            <span v-if="filters.frontPromType==15">满</span>
                            <span v-if="filters.frontPromType==16">买</span>
                            {{scope.row.conditionValue}}

                            <span v-if="filters.frontPromType==15">元，可换购；</span>
                            <span v-if="filters.frontPromType==16">件，可换购；</span>
                          </label>
                        </template>
                      </el-table-column>
                      <el-table-column label="操作" width="100">
                        <template slot-scope="scope">
                          <el-button
                            v-if="filters.promotionRules.length>1"
                            size="mini"
                            type="text"
                            @click="removePromotionRuleSet(scope.$index, scope.row)"
                          >删除</el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                    <el-button
                      v-if="filters.overlayAppFlag == 0"
                      size="mini"
                      type="primary"
                      @click="addPromotionRuleSet"
                      :disabled="filters.promotionRules.length > 4"
                    >新增优惠</el-button>
                  </div>
                </el-form-item>
              </el-row>


              <el-row class="pdL10 labelAlignment">
                <el-form-item label="活动描述：" prop="description" class="wid">
                  <el-input clearable
                            type="textarea"
                            :rows="2"
                            :placeholder="genDescriptionPlaceholder()"
                            class="activityDesc"
                            v-model="filters.description"
                            maxlength="100"
                            show-word-limit
                  >
                  </el-input>
                </el-form-item>
              </el-row>
              <el-row>
                <el-form-item label="" class="wid">
                  <div class="desc color666">
                    注：非必填字段，不填将显示系统默认文案（会存在某些促销类型无系统默认文案）。自定义输入活动规则描述描述后将显示在前台商品详情页中，请慎重填写。
                  </div>
                </el-form-item>
              </el-row>
            </div>
          </div>

          <div class="w100">
            <div class="title">
              交易规则：
            </div>
            <div class="item">
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="是否包邮：" prop="parcelsFlag" class="wid">
                  <el-radio-group v-model="filters.parcelsFlag">
                    <el-radio :label="1" class="form-radio mr40  radioAlignment w144 t_l noMarginLeft" border
                    >是</el-radio
                    >
                    <el-radio :label="0" class="form-radio radioAlignment w144 t_l noMarginLeft" border
                    >否</el-radio
                    >
                  </el-radio-group>
                </el-form-item>
              </el-row>
              <el-row class="m_b60 labelAlignment "  v-if="deptType != 3">
                <el-form-item
                  label="是否分摊："
                  prop="costAllocationFlag"
                  class="wid"
                >
                  <el-row class="m_b52">
                    <el-radio-group v-model="filters.costAllocationFlag">
                      <el-radio
                        :label="1"
                        class="form-radio mr40 radioAlignment w144 t_l noMarginLeft" border
                      >是</el-radio
                      >
                      <el-radio :label="0" class="form-radio radioAlignment w144 t_l noMarginLeft" border
                      >否</el-radio
                      >
                    </el-radio-group>
                  </el-row>
                  <div v-if="filters.costAllocationFlag == 1" class="rates">
                    <span>运营平台比例：</span>
                    <el-form-item prop="parentAllocationScale">
                      <el-input clearable
                                v-model="filters.parentAllocationScale"
                                auto-complete="off"
                                type="text"
                                :size="size"
                                class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                    <span>运营子平台比例：</span>
                    <el-form-item prop="childAllocationScale">
                      <el-input clearable
                                v-model="filters.childAllocationScale"
                                auto-complete="off"
                                type="text"
                                :size="size"
                                class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                    <span>商家比例：</span>
                    <el-form-item prop="merchantAllocationScale">
                      <el-input clearable
                                v-model="filters.merchantAllocationScale"
                                auto-complete="off"
                                type="text"
                                :size="size"
                                class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                    <span>店铺比例：</span>
                    <el-form-item prop="storeAllocationScale">
                      <el-input clearable
                                v-model="filters.storeAllocationScale"
                                auto-complete="off"
                                type="text"
                                :size="size"
                                class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                  </div>
                </el-form-item>
              </el-row>
            </div>
          </div>

          <div class="w100">
            <el-row class="title">
              参与条件：
            </el-row>
            <div class="item">
              <el-row v-if="deptType == 0" class="m_b52 ways labelAlignment">
                <el-form-item label="使用渠道：" class="wid contentPadding" :required="true">
                  <!-- <el-radio v-model="dataForm.channelIds" label="0" value="0">全平台（平台券）</el-radio>
                    <el-radio v-model="dataForm.channelIds" label="1" value="1">商家券</el-radio> -->
                  <el-tree
                    @check="channelChange"
                    :data="channelList"
                    :props="channlProps"
                    show-checkbox
                    :default-expand-all="true"
                    node-key="id"
                    ref="channelTree"
                  ></el-tree>
                </el-form-item>
              </el-row>
              <!--              <el-row>-->
              <!--                <el-form-item label="使用渠道" prop="channelCodes" class="wid">-->
              <!--                  <div style="width:100%;">-->
              <!--                    <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>-->
              <!--                    <el-checkbox-group v-model="filters.channelCodes" @change="handleCheckedCitiesChange">-->
              <!--                      <el-checkbox v-for="item in chanelCodesRadios" :label="item.code" :key="item.code">{{item.name}}</el-checkbox>-->
              <!--                    </el-checkbox-group>-->
              <!--                  </div>-->
              <!--                </el-form-item>-->
              <!--              </el-row>-->
              <el-row class="m_b52 labelAlignment">
<!--                <el-form-item label="新老用户：" prop="proUserType" class="wid">-->
<!--                  <el-radio-group v-model="filters.proUserType">-->
<!--                    <el-radio-->
<!--                      v-for="city in proUserTypeRadios"-->
<!--                      :label="city.code"-->
<!--                      :key="city.code"-->
<!--                      class="m_r45 radioAlignment"-->
<!--                    >{{ city.name }}</el-radio-->
<!--                    >-->
<!--                  </el-radio-group>-->
<!--                </el-form-item>-->
                <el-form-item label="新老用户：" prop="selectUserType" class="wid t_r" >
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w144 t_l mleft10"  border :indeterminate="userTypeIsIndeterminate" v-model="userTypeCheckAll" @change="handleCheckAllUserTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectUserType" @change="handleCheckedUserTypeChange">
                      <el-checkbox :label="1" :key="1" border class="mr40 el-checkBox-padding noMarginLeft w144 t_l">新用户</el-checkbox>
                      <el-checkbox :label="2" :key="2" border class="el-checkBox-padding noMarginLeft w144 t_l">老用户</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </el-form-item>
              </el-row>
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="会员类型：" prop="selectMemTypes" class="wid t_r" >
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w144 t_l mleft10" border :indeterminate="memTypeIsIndeterminate" v-model="memTypeCheckAll" @change="handleCheckAllMemTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectMemTypes" @change="handleCheckedMemTypeChange">
                      <el-checkbox :label="1" border :key="1" class="mr40 el-checkBox-padding noMarginLeft w144 t_l">普通会员</el-checkbox>
                      <el-checkbox :label="2" border :key="2" class="el-checkBox-padding noMarginLeft w144 t_l">VIP会员</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </el-form-item>
              </el-row>

              <el-row class="mb10 labelAlignment">
                <el-form-item prop="levelSelectList" class="wid errorTipsAlignment" >
                  <div class="mb20 ">
                    <span style="color:red">*</span>
                    <span class="color333 font16">会员等级：</span>
                  </div>
                  <div style="border:1px solid #ededed" class="ml7 pdl30 pdt20">
                  <div v-for="(memberGrade,index) in memberGradeList" :key="memberGrade.deptId" class="flexBox oh">
                    <div class="child-name mb20 oh">
                      <span class="turnInlineBlock w126 oe t_r h35 lh35 f_l">{{memberGrade.childName}}</span>
                      <span class="lh35 h35 f_l">：</span>
                    </div>
                    <div class="checkboxes">
                    <div>
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w144 t_l mleft10" border :indeterminate="memberGrade.isIndeterminate" v-model="memberGrade.checkAll" @change="handleMemLevelCheckAllChange(index,memberGrade.checkAll)">全选</el-checkbox>
                    </div>
                    <div>
                    <el-checkbox-group v-model="memberGrade.levelSelectList" >
                      <el-checkbox class=" mb20 mr40 el-checkBox-padding noMarginLeft w144 t_l" border @change="memLevelChange(index,memberGrade.levelList)" v-for="level in memberGrade.levelList" :checked="level.checked" v-model="level.id" :label="level.id" :key="level.key">
                      <span class="turnInlineBlock w104">{{level.levelName.length >= 6 ? level.levelName.slice(0,5)+"..." : level.levelName}}</span>  
                     </el-checkbox>
                    
                    </el-checkbox-group>
                    </div>
                    </div>
                  </div>
                  </div>
                </el-form-item>
              </el-row>
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="店铺地区：" class="wid"  :required="true">
                  <el-radio-group v-model="filters.storeArea">
                    <el-radio :label="-1" class="form-radio radioAlignment w144 t_l" border
                    >全国</el-radio
                    >
                  </el-radio-group>
                </el-form-item>
              </el-row>
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="用户地区：" class="wid"  :required="true">
                  <el-radio-group v-model="filters.userArea">
                    <el-radio :label="-1" class="form-radio radioAlignment w144 t_l" border
                    >全国</el-radio
                    >
                  </el-radio-group>
                </el-form-item>
              </el-row>
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="渠道：" class="wid t_r" label-width="122px"  :required="true">
                  <el-select v-model="filters.channelId" placeholder="请选择" size="mini" clearable class="width450">
                    <el-option
                      v-for="item in channelOption"
                      :key="item.id"
                      :label="item.channelName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-row>
              <el-row class="pdL50">
                <el-form-item label="备注：" class="wid">
                  <el-input clearable
                            type="textarea"
                            v-model="filters.remark"
                            @input="changeRemark($event)"
                            placeholder="请输入备注"
                            rows="2"
                            maxlength="100"
                            show-word-limit
                            class="remarks h286"
                  ></el-input>
                </el-form-item>
              </el-row>
            </div>
          </div>
        </el-form>
      </div>
      <div
        v-show="active == 2"
        class="tab-container tab-container-noPadding createSet "
      >
        <el-tabs type="border-card">
          <el-tab-pane label="商家">
            <el-row class="search-button-fix t_r">
              
              <div>
                <el-button
                  class="searchButton"
                  size="mini"
                  @click="searchMerchantFlag = !searchMerchantFlag"
                  icon="el-icon-search"
                >搜索</el-button>
                <el-button
                  class="searchButton"
                  size="mini"
                  @click="querySupplierListForAdd()"
                >添加商家</el-button
                >
                <el-button
                  class="resetButton"
                  size="mini"
                  @click="delAllSelectedSuppliermerchantTableData2()"
                >批量删除</el-button
                >
              </div>
            </el-row>

            <el-row>
              <div v-if="searchMerchantFlag" class="f_r mb30">
                <el-form
                  :inline="true"
                  :model="merchantSearchForm"
                  size="mini"
                  ref="merchantSearchForm"
                  :rules="merchantSearchFormRules"
                >
                  <!--                    merchantTableData2-->
                  <el-form-item label="商家编码：" prop="orgNumber" class="mr30">
                    <el-input v-model="merchantSearchForm.orgNumber" clearable maxlength="80" placeholder="商家编码"></el-input>
                  </el-form-item>
                  <el-form-item label="商家名称：" prop="merchantName">
                    <el-input clearable
                              v-model="merchantSearchForm.merchantName" maxlength="80" placeholder="商家名称"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="" prop="mpName">
                    <el-button
                      size="mini"
                      @click="resetMerchantSearch()"
                      class="resetButton"
                    >重置</el-button
                    >
                    <el-button
                      size="mini"
                      @click="merchantSearch()"
                      class="resetButton"
                    >查询</el-button
                    >
                    
                  </el-form-item>
                </el-form>
              </div>
            </el-row>

            <el-table
              :data="merchantTableData2"
              @selection-change="merchantTableData2selectionChange"
            >
              <el-table-column type="selection"></el-table-column>
              <el-table-column label="商家编号">
                <template slot-scope="scope">
                  <span>{{ scope.row.orgNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="name" label="商家名称">
                <template slot-scope="scope">
                  <span>{{ scope.row.name }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="type" label="商家类型">
                <template slot-scope="scope">
                  <!--<span>{{ scope.row.merchantType}}</span>-->
                  <span v-if="scope.row.merchantType == '1'">自营商家</span>
                  <span v-if="scope.row.merchantType == '2'">第三方商户</span>
                </template>
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button
                    type="text"
                    class="textButton"
                    @click="merchantTableData2delete(scope.row.id)"
                  >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
            <!--分页栏-->
            <div class="toolbar t_r">
              <el-pagination
                layout="total, sizes, prev, pager, next, jumper"
                @current-change="mainMerchantRefreshPageRequest"
                :current-page="merchantSearchForm.pageNo"
                :page-size="merchantSearchForm.pageSize"
                :total="mainMerchantTableDataTatol"
                :page-sizes="[10, 20, 30, 40]"
                @size-change="mainMerchantHandleSizeChange"
              ></el-pagination>
            </div>
          </el-tab-pane>

          <el-tab-pane label="店铺">
            <el-row class="search-button-fix t_r">
              
              <div>
                <el-button
                  class="searchButton"
                  size="mini"
                  @click="searchStoreFlag = !searchStoreFlag"
                  icon="el-icon-search"
                >搜索</el-button>
                <el-button
                  class="searchButton"
                  size="mini"
                  @click="querySupplierListForAdd2()"
                >添加店铺</el-button
                >
                <el-button
                  class="resetButton"
                  size="mini"
                  @click="delAllSelectedSupplierstoreTableData()"
                >批量删除</el-button
                >
              </div>
            </el-row>

            <el-row>
                <div v-if="searchStoreFlag" class="f_r mb30">
                  <el-form
                    :inline="true"
                    :model="storeSearchForm"
                    size="mini"
                    ref="storeSearchForm"
                    :rules="storeSearchFormRules"
                  >
                    <!--                    merchantTableData2-->
                    <el-form-item
                      label="店铺编码："
                      prop="storecode"
                      class="mr30"
                    >
                      <el-input clearable
                                v-model="storeSearchForm.storecode"
                                @change="changeInput($event)" maxlength="80" placeholder="店铺编码"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="店铺名称：" prop="storename">
                      <el-input clearable
                                v-model="storeSearchForm.storename"
                                @change="changeInput($event)" maxlength="80" placeholder="店铺名称"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="mpName">
                      <el-button
                        size="mini"
                        @click="resetStoreSearch()"
                        class="resetButton"
                      >重置</el-button
                      >
                      <el-button
                        size="mini"
                        @click="storeSearch()"
                        class="resetButton"
                      >查询</el-button
                      >
                      
                    </el-form-item>
                  </el-form>
                </div>
              </el-row>

            <el-table
              :data="storeTableData"
              @selection-change="storeTableDataselectionChange"
            >
              <el-table-column type="selection"></el-table-column>
              <el-table-column label="店铺编号">
                <template slot-scope="scope">
                  <span>{{ scope.row.storecode }}</span>
                </template>
              </el-table-column>

              <el-table-column label="店铺名称">
                <template slot-scope="scope">
                  <span>{{ scope.row.storename }}</span>
                </template>
              </el-table-column>
              <el-table-column label="店铺类型">
                <template slot-scope="scope">
                  <span v-if="scope.row.storeType == '1'">线上店铺</span>
                  <span v-else>线下店铺</span>
                </template>
              </el-table-column>
               <el-table-column label="所属商家">
                <template slot-scope="scope">
                  <span>{{ scope.row.merchantName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button
                    type="text"
                    class="textButton"
                    @click="storeDelete(scope.row.id)"
                  >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
            <!--分页栏-->
            <div class="toolbar t_r">
              <el-pagination
                layout="total, sizes, prev, pager, next, jumper"
                @current-change="mainSroreMerchantRefreshPageRequest"
                :current-page="storeSearchForm.pageNo"
                :page-size="storeSearchForm.pageSize"
                :total="storeTableDataTatol"
                style="float:right;"
                :page-sizes="[10, 20, 30, 40]"
                @size-change="mainSroreMerchantHandleSizeChange"
              ></el-pagination>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
      <!--促销商品列表-->
      <div
        v-if="active == 3"
        class=" createSet tab-container active3"
      >
        <el-tabs type="border-card" @tab-click="handleProductClick">
          <el-tab-pane label="参与商品">
            <el-tabs type="border-card" @tab-click="handleClickMerchantProduct">
                <el-tabs v-model="productStatusTabs" @tab-click="productTabs">
                  <el-tab-pane :label="'生效商品('+ (Number(merchantProductTotalCount) > 9999 ? '9999+' : merchantProductTotalCount) +')'" name="1">
                      <el-form :inline="true" class="demo-form-inline2" size="small">
                        <div class="row-line-button w100 t_r" >
                          <div style="width:100%">
                            <el-button
                              class="searchButton"
                              size="mini"
                              @click="changeSearchMerchantProductFlag"
                              icon="el-icon-search"
                            >搜索</el-button
                            >
                            <el-button class="searchButton" size="mini" @click="add"
                            >添加促销商品</el-button
                            >
                            <el-button
                              class="resetButton"
                              size="mini"
                              @click="batchDelProduct"
                            >批量删除</el-button
                            >
                            <el-button
                              icon="el-icon-document"
                              size="mini"
                              type="primary"
                              @click="downloadTemplate"
                              style="margin-right: 15px;"
                              v-if="false"
                              class="searchButton"
                            >模板下载</el-button
                            >
                            <el-upload
                              class="avatar-uploader"
                              :show-file-list="false"
                              accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
                              v-if="false"
                            >
                              <el-button
                                icon="el-icon-document-add"
                                size="mini"
                                type="primary"
                                v-if="false"
                                class="searchButton"
                              >商品导入</el-button
                              >
                            </el-upload>

                          </div>
                        </div>
                      </el-form>
                      <el-row>
                        <div v-if="searchMerchantProductFlag" class="mb30">
                          <el-form
                            :inline="true"
                            :model="merchantProductSearchForm"
                            size="mini"
                            ref="merchantProductSearchForm"
                            class="rightForm"
                            :rules="merchantProductSearchFormRules"
                          >
                            <!--                    merchantTableData2-->
                            <el-form-item label="店铺：" prop="storeId">
                              <template>
                                <el-select
                                  v-model="merchantProductSearchForm.storeId"
                                  placeholder="全部" clearable
                                >
                                  <el-option
                                    v-for="item in promotionStoreTableData"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                                  >
                                  </el-option>
                                </el-select>
                              </template>
                            </el-form-item>
                            <el-form-item label="商品编码：" prop="mpCode">
                              <el-input clearable
                                        v-model="merchantProductSearchForm.mpCode" maxlength="80" placeholder="商品编码"
                              ></el-input>
                            </el-form-item>
                            <el-form-item label="商品名称：" prop="mpName">
                              <el-input clearable
                                        v-model="merchantProductSearchForm.mpName" maxlength="80" placeholder="商品名称"
                              ></el-input>
                            </el-form-item>
                            <el-form-item label="商品分类：" prop="categoryName">
                              <el-input clearable
                                        v-model="merchantProductSearchForm.categoryName" maxlength="80" placeholder="商品分类"
                              ></el-input>
                            </el-form-item>
                            <el-form-item>
                              <el-button
                                size="mini"
                                @click="resetMerchantProductSearch()"
                                class="resetButton"
                              >重置</el-button
                              >
                              <el-button size="mini" @click="merchantProductSearch()"  type="primary"
                              class="resetButton"
                              >查询</el-button
                              >
                              
                            </el-form-item>
                          </el-form>
                        </div>
                      </el-row>
                    <div class="tableTree">
                      
                      <el-table :data="merchantProductTableData"  row-key="id" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                                @selection-change="repelSelectionChange" style="width: 100%" class="tableStyle">
                        <!-- <el-table-column type="selection" width="55"></el-table-column> -->
                        <el-table-column align="left" width="30">
                          <template slot="header" slot-scope="scope">
                            <div class="isAllChecked" v-if="merchantProductTableData.length > 0">
                              <el-checkbox
                                :indeterminate="isIndeterminateProductCheck"
                                v-model="isAllProductChecked"
                                @change="handleCheckedAllProductChange"
                              ></el-checkbox>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column width="40">
                          <template slot-scope="scope">
                            <el-checkbox
                              :indeterminate="scope.row.isIndeterminateCheck"
                              v-model="scope.row.isCheck"
                              @change="handleCheckedProductChange(scope.row,$event)"
                            ></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="mpCode"
                          label="商品编码"
                          align="left"
                        >
                        </el-table-column>
                        <el-table-column
                          prop="productName"
                          label="商品名称"
                          sortable
                          align="center"
                        >
                          <template slot-scope="scope">
                            <span>{{ scope.row.mpName }}</span>
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="categoryName"
                          label="商品分类"
                          align="center"
                        >
                          <template slot-scope="scope">
                            <span>{{ scope.row.categoryName }}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="stock" label="库存" align="center">
                          <template slot-scope="scope">
                            <span>{{ scope.row.stock }}</span>
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="storeName"
                          label="所属店铺"
                          align="center"
                        >
                          <template slot-scope="scope">
                            <span>{{ scope.row.storeName }}</span>
                          </template>
                        </el-table-column>

                        <el-table-column
                          prop="salePrice"
                          label="零售（元）"
                          align="center"
                        >
                          <template slot-scope="scope">
                            <span>{{ scope.row.salePrice }}</span>
                          </template>
                        </el-table-column>

                        <el-table-column
                          label="操作"
                          fixed="right"
                          align="center"
                        >
                          <template slot-scope="scope">
                            <el-button
                              @click.native.prevent="
                                delMerchantProducts(scope.row.id)
                              "
                              type="text"
                              size="small"
                            >
                              删除
                            </el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                      <!--分页栏-->
                      <div class="toolbar t_r" >
                        <el-pagination
                          @size-change="handleSizeChangeMerchantProductTableData"
                          @current-change="
                            handleCurrentChangeMerchantProductTableData
                          "
                          :current-page="merchantProductSearchForm.start"
                          :page-sizes="[10]"
                          :page-size="merchantProductSearchForm.limit"
                          layout="total, sizes, prev, pager, next, jumper"
                          :total="merchantProductTableDataTotal"
                        >
                        </el-pagination>
                      </div>
                      </div>
                  </el-tab-pane>
                  <el-tab-pane :label="'互斥商品('+ (Number(mutexMerchantProductTotalCount) > 9999 ? '9999+' : mutexMerchantProductTotalCount) +')'" name="2">
                    <div class="row-line-button t_r">
                      <div style="width:100%">
                        <!-- <el-button type="primary" size="mini" @click="addAllProduct">全部添加</el-button> -->
                        <!-- <el-button type="primary" size="mini" @click="add">添加促销商品</el-button> -->
                        <el-button class="searchButton"  @click="batchRenewAdd">批量重新添加</el-button>
                      </div>
                    </div>
                    <div class="tableTree">
                      
                      <el-table :data="mutexProductList"  row-key="id" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                                @selection-change="batchRenewAddSelectionChange" style="width: 100%" class="tableStyle">
                        <!-- <el-table-column type="selection" width="55"></el-table-column> -->
                        <el-table-column align="left" width="30">
                          <template slot="header" slot-scope="scope">
                            <div class="isAllChecked" v-if="mutexProductList.length > 0">
                              <el-checkbox
                                :indeterminate="isIndeterminateCheck"
                                v-model="isAllChecked"
                                @change="handleCheckedAllChange"
                              ></el-checkbox>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column width="40">
                          <template slot-scope="scope">
                            <el-checkbox
                              :indeterminate="scope.row.isIndeterminateCheck"
                              v-model="scope.row.isCheck"
                              @change="handleCheckedChange(scope.row,$event)"
                            ></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column prop="mpCode" label="商品编码" width="200"  align="left"></el-table-column>
                        <el-table-column prop="mpName" label="商品名称" width="200"></el-table-column>
                        <el-table-column prop="categoryName" label="商品分类" width="200"></el-table-column>
                        <el-table-column prop="stock" label="库存" width="200"></el-table-column>
                        <el-table-column prop="salePrice" label="原价（元）" width="200"></el-table-column>
                        <el-table-column prop="storeName" label="所属店铺" width="200"></el-table-column>
                        <el-table-column align="center" fixed="right" label="操作" width="390">
                          <template slot-scope="scope">
                            <el-button @click="getMutexInfo(scope.row)" v-if="scope.row.typeOfProduct==20" type="text" class="textButton" size="small">查看详情</el-button>
                            <el-button @click="renewAdd(scope.row)" v-if="scope.row.typeOfProduct==10 || scope.row.typeOfProduct==20" type="text" class="textButton" size="small">重新添加</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                      <div class="toolbar t_r" >
                        <el-pagination
                          @size-change="handleSizeChangeMutexProductList"
                          @current-change="handleCurrentChangeMutexProductList"
                          :current-page="mutexProductForm.start"
                          :page-sizes="[10, 20, 30, 40]"
                          :page-size="mutexProductForm.limit"
                          layout="total, sizes, prev, pager, next, jumper"
                          :total="mutexProductTotal"
                        >
                        </el-pagination>
                      </div>
                    </div>
                  </el-tab-pane>
                </el-tabs>
            </el-tabs>
          </el-tab-pane>
          <el-tab-pane label="换购商品">
            <!-- 促销赠品设置 -->
            <div>
              <div>
                <el-table :data="giftRuleTable" >
                  <el-table-column
                    label="优惠阶梯"
                    type="index"
                    width="200px"
                  ></el-table-column>
                  <el-table-column label="促销规则">
                    <template slot-scope="scope">
                      <span v-if="filters.frontPromType==15">满</span>
                      <span v-else>买</span>
                      <el-input clearable
                                size="mini"
                                style="width:300px"
                                v-model="scope.row.conditionValue"
                                :disabled="true"
                                @blur="updatePromotionRule(scope.row)"
                      />
                      <span v-if="filters.frontPromType == 15">元</span>
                      <span v-else>件</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="促销赠品">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        @click="addPro(scope.$index, scope.row)"
                      >添加换购商品</el-button
                      >
                      <el-button size="mini" @click="checkPro(scope.row)"
                      >查看换购商品</el-button
                      >
                    </template>
                  </el-table-column>
                  <el-table-column prop="operating" label="操作" v-if="false">
                    <template slot-scope="scope">
                      <el-button
                        @click.native.prevent="deleteGiftRule(scope.row)"
                        type="text"
                        size="small"
                        v-if="[1, 2].includes(filters.status)"
                      >删除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div style="text-align:left;margin-top:15px;" v-if="false">
                <el-button
                  size="mini"
                  @click="addGiftRule"
                  v-if="[1, 2].includes(filters.status)"
                  class="searchButton"
                >新增优惠</el-button
                >
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
      <!--step3##111end-->
      <div class="tab-container tab-success createSet" v-show="active == 4">
        <div class="titleInfo">
          <img src="/static/images/success.png"/>
          <span class="font20">活动创建成功!</span>
        </div>

        <div class="step-button2">
          <el-button type="primary" plain @click="detailList" class="resetButton">查看活动列表</el-button>
          <template  v-if="(4==filters.status && auditCount == 0) || [9, 1].includes(filters.status)">
            <kt-button
              type="primary"
              class="searchButton"
              :size="size"
              @click="shenheHuodong(0)"
              perms="market:increase:submit"
              label="提交审核"
            ></kt-button>
          </template >
          <template   v-if="[2].includes(filters.status)">
            <kt-button
              type="primary"
              class="searchButton"
              :size="size"
              @click="shenheHuodong(1)"
              perms="market:increase:verify"
              label="审核"
            ></kt-button>
          </template >
          <template  style="margin-top:20px;">
            <kt-button
              type="primary"
              class="searchButton"
              :size="size"
              @click="saveTemplateDialog"
              perms="market:increase:addtemp"
              label="保存模板"
            ></kt-button>
          </template >
        </div>
      </div>
    </div>
    <!--下一步按钮-->
    <div class="step-button">
      <el-button
        type="primary"
        :size="size"
        :plain="active != 1 && active != 4"
        v-if="active != 1 && active != 4"
        @click="back"
        class="cancelButton"
      >上一步</el-button
      >
      <el-button type="primary" @click="next" v-show="active != 4" :size="size"
      class="searchButton"
      >下一步</el-button
      >
    </div>
    <!-- 选择参与商家 -->
    <el-dialog
      :title="'添加商家'"
      :visible.sync="editDialogVisible"
      :close-on-click-modal="false"
    >
      <div>
        <div >
          <el-form
            :inline="true"
            :model="merchantForm"
            size="mini"
            ref="merchantForm"
            :rules="merchantFormRules"
          >
            <el-form-item label="商家编号：" prop="orgNumber" class="w178">
              <el-input clearable
                        v-model="merchantForm.orgNumber"
                        placeholder="商家编号" maxlength="80"
                        size="mini"
              ></el-input>
            </el-form-item>
            <el-form-item label="商家名称：" prop="name" class="w178">
              <el-input clearable
                        v-model="merchantForm.name"
                        placeholder="商家名称" maxlength="80"
                        size="mini"
              ></el-input>
            </el-form-item>
            <el-form-item label="商家类型：" prop="merchantType" class="w178">
              <el-select v-model="merchantForm.merchantType" placeholder="全部" clearable>
<!--                <el-option label="全部" value=""></el-option>-->
                <el-option label="自营商家" value="1"></el-option>
                <el-option label="第三方商户" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-row class="t_r mb30 mt20">
            <el-button size="mini" type="primary" plain @click="resetMerchantForm()" class="resetButton" icon="el-icon-refresh">重置</el-button>
            <el-button size="mini" type="primary" @click="merchantFormFind()" icon="el-icon-search" class="searchButton">搜索</el-button>
            
          </el-row>
        </div>
        <div>
          <el-table
            :data="merchantTableData"
            @selection-change="addSelectionChange"
          >
            <el-table-column type="selection"></el-table-column>
            <el-table-column align="center" label="商家编号">
              <template slot-scope="scope">
                <span>{{ scope.row.orgNumber }}</span>
              </template>
            </el-table-column>
            <el-table-column width="389px" align="center" label="商家名称">
              <template slot-scope="scope">
                <span>{{ scope.row.name }}</span>
              </template>
            </el-table-column>
            <el-table-column width="300px" align="center" label="商家类型">
              <template slot-scope="scope">
                <span v-if="scope.row.merchantType =='1'">自营商家</span>
                  <span v-if="scope.row.merchantType =='2'">第三方商户</span>
              </template>
            </el-table-column>
          </el-table>
          <!--分页栏-->
          <div class="toolbar t_r" v-if="merchantTableData.length > 0">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="refreshPageRequest"
              :current-page="merchantForm.start"
              :page-size="merchantForm.limit"
              :total="merchantTableDataTatol"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="handleSizeChange"
            ></el-pagination>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button type="primary" plain :size="size" @click.native="editDialogVisible = false"
        class="cancelButton"
        >取消</el-button
        >
        <el-button
          :size="size"
          type="primary"
          @click.native="editDialogVisible = false"
          @click="merchantTableDataSubmit"
          class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 选择参与店铺 -->
    <el-dialog
      :title="'添加参与店铺'"
      :visible.sync="editDialogVisible2"
      :close-on-click-modal="false"
    >
      <div>
        <div>
          <el-form
            :inline="true"
            :model="storeForm"
            size="mini"
            ref="storeForm"
            :rules="storeFormRules"
          >
            <el-form-item label="店铺名称：" prop="storename" class="w178 mb30">
              <el-input clearable
                        v-model="storeForm.storename"
                        size="mini" maxlength="80" placeholder="店铺名称"
              ></el-input>
            </el-form-item>
            <el-form-item label="店铺编号：" prop="storecode" class="w178">
              <el-input clearable
                        v-model="storeForm.storecode"
                        placeholder="店铺编号" maxlength="80"
                        size="mini"
              ></el-input>
            </el-form-item>
            <el-form-item label="所属商家名称：" prop="merchantName" class="w178">
              <el-input clearable
                        v-model="storeForm.merchantName"
                        placeholder="所属商家名称" maxlength="80"
                        size="mini"
              ></el-input>
            </el-form-item>
             <el-form-item label="店铺类型：" prop="storeType" class="w178">
              <el-select v-model="storeForm.storeType" placeholder="全部" size="mini" clearable>
<!--                <el-option label="全部" value=""></el-option>-->
                <el-option label="自营店铺" value="0"></el-option>
                <el-option label="入驻店铺" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-row class="mb30 t_r  mt20">
            <el-button size="mini" type="primary" plain @click="resetStoreForm()"
            class="resetButton"
            icon="el-icon-refresh"
            >重置</el-button
            >
            <el-button
              size="mini"
              type="primary"
              @click="storeFormFind()"
              icon="el-icon-search"
              class="searchButton"
            >搜索</el-button
            >
            
          </el-row>
        </div>
        <div>
          <el-table
            :data="storeTableData2"
            @selection-change="storeTableData2AddSelectionChange"
          >
            <el-table-column type="selection"></el-table-column>
            <el-table-column prop="id" label="店铺编号" width="320">
              <template slot-scope="scope">
                <span>{{ scope.row.storeCode }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="productName" label="店铺名称">
              <template slot-scope="scope">
                <span>{{ scope.row.storeName }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="storeType" label="店铺类型">
              <template slot-scope="scope">
                <span v-if="scope.row.storeType == '0'">自营店铺</span>
                <span v-if="scope.row.storeType == '1'">入驻店铺</span>
              </template>
            </el-table-column>
            <el-table-column prop="merchantName" label="所属商家">
              <template slot-scope="scope">
                <span>{{ scope.row.merchantName }}</span>
              </template>
            </el-table-column>
          </el-table>
          <!--分页栏-->
          <div class="toolbar t_r" v-if="storeTableData2.length > 0">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="refreshPageRequestStore"
              :current-page="merchantFormStore.start"
              :page-size="merchantFormStore.limit"
              :total="merchantTableDataTatolStore"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="handleSizeChangeStore"
            ></el-pagination>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button
          :size="size"
          @click.native="editDialogVisible2 = false"
          type="primary"
          plain
          class="cancelButton"
        >取消</el-button
        >
        <el-button
          :size="size"
          type="primary"
          @click.native="editDialogVisible2 = false"
          @click="storeTableData2Click"
          class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 导入、上传弹窗-->
    <el-dialog
      class="el-dialog-style"
      :title="operation ? '商品导入' : '下载模板'"
      :inline="true"
      :visible.sync="uploadVisible"
      :close-on-click-modal="false"
    >
      <div >
        <el-button type="primary" icon="el-icon-download" v-show="operation"
        class="searchButton"
        >商品导入模板</el-button
        >
        <el-button
          type="primary"
          icon="el-icon-upload"
          v-show="operation == false"
          class="searchButton"
        >商品导入</el-button
        >
      </div>
    </el-dialog>

    <!--新增编辑界面:添加赠品商品-->
    <el-dialog
      :title="giftAddFlag ? '添加换购商品' : '查看换购商品'"
      :inline="true"
      :visible.sync="giftProductVisible"
      :close-on-click-modal="false"
    >

      <div v-if="giftAddFlag">
        <div>
          <el-form
            :model="giftProductForm"
            ref="giftProductForm"
            :size="size"
            :inline="true"
          >
            <el-form-item label="商品名称：" prop="goodsName" class="w178">
              <el-input clearable
                        v-model="giftProductForm.goodsName"
                        auto-complete="off" placeholder="商品名称" maxlength="80"
              ></el-input>
            </el-form-item>
            <el-form-item label="商品编号：" prop="thirdSkuId" class="w178">
              <el-input clearable
                        v-model="giftProductForm.thirdSkuId" placeholder="商品编号"
                        auto-complete="off" maxlength="80"
              ></el-input>
              </el-form-item>
              <el-form-item label="商品分类：" prop="goodsCategory" class="w178">
                <el-input clearable
                          v-model="giftProductForm.goodsCategory" placeholder="商品分类"
                          auto-complete="off" maxlength="80"
                ></el-input>
              </el-form-item>

          </el-form>
          <div class="mb30 t_r mt20">
            <el-button size="mini" plain @click="resetGiftProductForm()" type="primary" class="resetButton" icon="el-icon-refresh">重置</el-button>
            <el-button size="mini" @click="giftProductFormFind()" type="primary" icon="el-icon-search" class="searchButton">搜索</el-button>
            
          </div>
        </div>
      </div>
      <div v-if="!giftAddFlag">
        <el-form
          :model="seeGiftProductForm"
          ref="seeGiftProductForm"
          :size="size"
          :inline="true"
        >
          <div>
            <el-form-item label="商品名称：" prop="mpName" class="w178">
              <el-input clearable
                        v-model="seeGiftProductForm.mpName"
                        auto-complete="off" placeholder="商品名称" maxlength="80"
              ></el-input>
            </el-form-item>
            <el-form-item label="商品编号：" prop="mpCode" class="w178">
              <el-input clearable
                        v-model="seeGiftProductForm.mpCode"
                        auto-complete="off" placeholder="商品编号" maxlength="80"
              ></el-input>
            </el-form-item>
            <el-form-item label="商品分类：" prop="goodsCategory" class="w178" v-if="false">
              <el-input clearable
                        v-model="seeGiftProductForm.goodsCategory"
                        auto-complete="off" placeholder="商品分类" maxlength="80"
              ></el-input>
            </el-form-item>
          </div>
        </el-form>
        <div class="mb30 mt20 t_r">
          <!--            <el-button  size="mini" @click="productFormFind()">查询</el-button>-->
          <el-button size="mini" @click="resetSeeGiftProductForm()" type="primary" class="resetButton" icon="el-icon-refresh"
          >重置</el-button
          >
          <el-button size="mini" @click="checkPro(null)" class="searchButton" icon="el-icon-search">
            搜索
          </el-button>
          
        </div>
      </div>
      <div >
        <el-table
          :data="giftProductTableData"
          @selection-change="addSelectionChangeGiftProduct"
        >
          <el-table-column
            type="selection"
            width="55"
            v-if="giftAddFlag"
            key="1"
          ></el-table-column>
          <el-table-column
            prop="code"
            label="商品编码"
            align="center"
            key="2"
            width="300"
          ></el-table-column>
          <el-table-column
            prop="chineseName"
            label="商品名称"
            align="center"
            key="4"
            width="250"
          ></el-table-column>
           <el-table-column
            prop="goodsCategory"
            label="商品分类"
            align="center"
            key="3"
            width="150"
          ></el-table-column>
          <el-table-column
            prop="storeName"
            label="所属店铺"
            align="center"
            key="6"
            width="150"
          ></el-table-column>
          <el-table-column
            prop="salePrice"
            label="原价"
            align="center"
            key="7"
            width="150"
          ></el-table-column>
          <el-table-column
            prop="stock"
            label="库存"
            align="center"
            key="15"
            width="150"
          ></el-table-column>
          <el-table-column prop="giftNum" label="换购价" align="center" key="8" width="150">
            <template slot-scope="scope" prop="upgradeAmount" align="center">
              <el-input clearable
              class="iconAlignment"
              v-model="scope.row.upgradeAmount"
                        v-if="giftAddFlag" placeholder="换购价"
              @blur="updateGiftItem(scope.row)" maxlength="10">
              </el-input>
              <span v-else>{{scope.row.upgradeAmount  || '-'}}</span>
              </template>
          </el-table-column>
          <!-- <el-table-column
            prop="channelMerchantLimit"
            label="商家限购" v-if="false"
            align="center"
            key="9"
          >
            <template
              slot-scope="scope"
              prop="channelMerchantLimit"
              align="center"
            >
              <el-input clearable
              class="iconAlignment"
                v-model="scope.row.channelMerchantLimit"
                @blur="updateGiftItem(scope.row)"
              ></el-input>
            </template>
          </el-table-column> -->
          <el-table-column

            prop="channelStoreLimit"
            label="店铺限购"
            align="center"
            key="11"
            width="150"
          >
            <template slot-scope="scope">
              <el-input clearable
              class="iconAlignment"
                v-model="scope.row.channelStoreLimit"
                        v-if="giftAddFlag"  placeholder="店铺限购"
                @blur="updateGiftItem(scope.row)" maxlength="10"
              />
              <span v-else>{{scope.row.channelStoreLimit  || '-'}}</span>
            </template>
          </el-table-column>
          <el-table-column

            prop="channelIndividualLimit"
            align="center"
            label="个人限购"
            key="10"
            width="150"
          >
            <template slot-scope="scope">
              <el-input clearable
               class="iconAlignment"
                @blur="updateGiftItem(scope.row)"
                        v-if="giftAddFlag" placeholder="个人限购"
                v-model="scope.row.individualLimit" maxlength="10"

              />
              <span v-else>{{scope.row.individualLimit  || '-'}}</span>
            </template>
          </el-table-column>

          <el-table-column
            label="操作"
            align="center"
            v-if="!giftAddFlag"
            key="12"
            fixed="right"
            width="150"
          >
            <template slot-scope="scope">
              <el-button
                type="text"
                class="textButton"
                @click="deleteGiftItem(scope.row.itemId)"
              >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <!--分页栏-->
        <div
          class="toolbar t_r"
          v-if="giftAddFlag && giftProductTableData.length > 0"
        >
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            @current-change="handleCurrentChangeForGiftProduct"
            :current-page="giftProductForm.start"
            :page-size="giftProductForm.limit"
            :total="giftProductTableDataSize"
            :page-sizes="[10, 20, 30, 40]"
            @size-change="handleSizeChangeForGiftProduct"
          ></el-pagination>
        </div>
        <div
          class="toolbar t_r"
          v-if="!giftAddFlag && giftProductTableData.length > 0"
        >
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            @current-change="handleCurrentChangeForSeeGiftProduct"
            :current-page="seeGiftProductForm.start"
            :page-size="seeGiftProductForm.limit"
            :total="seeGiftProductTableDataSize"
            :page-sizes="[10, 20, 30, 40]"
            @size-change="handleSizeChangeForSeeGiftProduct"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="giftProductVisible = false" class="cancelButton"
        >取消</el-button
        >
        <el-button
          :size="size"
          type="primary"
          @click="giftProductTableData2Click"
          :loading="giftProductEditLoading"
          class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      :title="'互斥提示'"
      :visible.sync="mutexDetailDialogVisible"
      :close-on-click-modal="false"
    >
      <div>
        <div >
          <el-row>
            <el-col class="mb20 t_l">以下商品正在参与同类型的促销活动，本次新增将无法生效！ </el-col>
          </el-row>
          <el-table :data="mutexPromotionTable"  style="width: 100%">
            <el-table-column width="285px" align="center" label="互斥活动ID">
              <template slot-scope="scope">
                <span>{{ scope.row.promotionId }}</span>
              </template>
            </el-table-column>
            <el-table-column width="285px" align="center" label="互斥活动名称">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  class="textButton"
                  @click="seeMoreDeatil(scope.row)"
                >{{ scope.row.promName }}</el-button
                >
                <!--                <span>{{ scope.row.promName}}</span>-->
              </template>
            </el-table-column>
            <el-table-column width="285px" align="center" label="互斥活动时间">
              <template slot-scope="scope">
                <span>{{ scope.row.mutexTime }}</span>
              </template>
            </el-table-column>
            <el-table-column width="285px" align="center" label="互斥渠道">
              <template slot-scope="scope">
                <span>{{ scope.row.mutexChannel }}</span>
              </template>
            </el-table-column>
            <el-table-column width="285px" align="center" label="互斥商户">
              <template slot-scope="scope">
                <span>{{ scope.row.mutexStroeName }}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="mutexDetailDialogVisible = false" class="searchButton">关闭</el-button>
      </div>
    </el-dialog>

    <!--添加赠品-优惠券-->
    <el-dialog
      title="添加优惠券"
      :inline="true"
      :visible.sync="giftCouponsVisible"
      :close-on-click-modal="false"
    >
      <div v-if="giftCouponsAddFlag">
        <el-form
          :model="giftCouponsForm"
          label-width="90px"
          ref="giftCouponsForm"
          :size="size"
        >
          <div style="display: flex;align-content: flex-start;flex-wrap: wrap;">
            <el-form-item label="优惠券名称" prop="couponName">
              <el-input clearable
                        v-model="giftCouponsForm.couponName"
                        style="width: 215px"
                        auto-complete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="优惠券id" prop="couponId">
              <el-input clearable
                        v-model="giftCouponsForm.couponId"
                        style="width: 215px"
                        auto-complete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="优惠券面额" prop="couponAmountStart">
              <el-input clearable
                        v-model="giftCouponsForm.couponAmountStart"
                        style="width: 215px"
                        auto-complete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="至" prop="couponAmountEnd">
              <el-input clearable
                        v-model="giftCouponsForm.couponAmountEnd"
                        style="width: 215px"
                        auto-complete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="优惠券有效时间" prop="couponId">
              <el-date-picker
                v-model="giftCouponsForm.activityStartTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                placeholder=""
                class="input_postion"
                size="mini"
              ></el-date-picker
              >至
              <el-date-picker
                v-model="giftCouponsForm.activityEndTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                placeholder=""
                class="input_postion"
                size="mini"
              ></el-date-picker>
            </el-form-item>
          </div>
          <div style="margin-left: 21px;">
            <el-button size="mini" @click="resetGiftCouponsForm()" class="resetButton" icon="el-icon-refresh"
            >重置</el-button
            >
            <el-button size="mini" @click="giftCouponsFormFind" class="searchButton" icon="el-icon-search">搜索</el-button>
            
          </div>
        </el-form>
      </div>
      <div v-if="false && !giftCouponsAddFlag">
        <el-form
          :model="giftCouponsForm"
          label-width="90px"
          ref="giftProductForm"
          :size="size"
        >
          <div style="display: flex;align-content: flex-start;flex-wrap: wrap;">
            <el-form-item label="优惠券id" prop="couponId">
              <el-input clearable
                        v-model="giftCouponsForm.couponId"
                        style="width: 215px"
                        auto-complete="off"
              ></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <div style="padding-top: 45px;">
        <el-table
          :data="giftCouponsTableData"
          @selection-change="addSelectionChangeGiftCoupons"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column width="285px" align="center" label="优惠券id">
            <template slot-scope="scope">
              <span>{{ scope.row.couponId }}</span>
            </template>
          </el-table-column>
          <el-table-column width="285px" align="center" label="优惠券名称">
            <template slot-scope="scope">
              <span>{{ scope.row.couponName }}</span>
            </template>
          </el-table-column>
          <el-table-column width="285px" align="center" label="面值">
            <template slot-scope="scope">
              <span>{{ scope.row.couponAmount }}</span>
            </template>
          </el-table-column>
          <el-table-column width="285px" align="center" label="有效时间">
            <template slot-scope="scope">
              <span
              >{{ scope.row.couponUseStartTime }}-{{
                  scope.row.couponUseEndTime
                }}</span
              >
            </template>
          </el-table-column>
          <el-table-column prop="giftNum" label="每人限领（张）" align="center">
            <template slot-scope="scope" prop="giftNum" align="center">
              <el-input clearable v-model="scope.row.channelIndividualLimit"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="giftNum" label="使用条件" align="center">
            <span>满{{ currentRule.contentValue }}可用</span>
          </el-table-column>
          <el-table-column label="总量限制/已发行量" align="center">
            <template slot-scope="scope">
              <span
              >{{ scope.row.grantTotalNum }}/{{
                  scope.row.useTotalAmountLimit
                }}</span
              >
            </template>
          </el-table-column>
        </el-table>
        <!--分页栏-->
        <div class="toolbar t_r"  v-if="giftCouponsAddFlag">
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            @current-change="handleCurrentChangeForGiftCoupons"
            :current-page="giftCouponsForm.start"
            :page-size="giftCouponsForm.limit"
            :total="giftCouponsTableDataSize"
            style="float:right;"
            :page-sizes="[10, 20, 30, 40]"
            @size-change="handleSizeChangeForGiftCoupons"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button type="primary" plain :size="size" @click.native="giftCouponsVisible = false" class="cancelButton">取消</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="giftCouponsVisible = false"
          @click="giftCouponsTableData2Click"
          :loading="giftCouponsEditLoading"
          class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      title="添加标签"
      :visible.sync="addTagDialogFormVisible"
      class="el-dialog-style addTags"
    >
      <el-form :model="addTagForm" :rules="addTagRules" ref="addTagForm">
        <el-form-item
          label="标签分类："
          label-width="130px"
          prop="categoryId"
          class="mb30"
        >
          <el-select
            v-model="addTagForm.categoryId"
            placeholder="请选择分类标签" clearable
          >
            <el-option
              v-for="item in tagCategoryList"
              :key="item.id"
              :label="item.categoryName"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="标签名称："
          label-width="130px"
          prop="tagName"
        >
          <el-input clearable
                    placeholder="请输入标签名称"
                    v-model="addTagForm.tagName"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="addTagDialogFormVisible = false" size="mini" class="cancelButton"
        >取消</el-button
        >
        <el-button type="primary" @click="addNewTag" size="mini" class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>

    <!--保存模板弹窗-->
    <el-dialog
      title="添加模板"
      :visible.sync="templateDialogVisible"
      :close-on-click-modal="false"
      class="el-dialog-style"
    >
      <el-form
        :model="templateDataForm"
        label-width="130px"
        :size="size"
        ref="templateDataForm"
        :rules="templateDataFormRules"
      >
        <el-form-item label="模板名称：" prop="templateName">
          <el-input clearable
                    placeholder="输入模板名称"
                    v-model="templateDataForm.templateName"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" >
        <el-button  type="primary" plain :size="size" @click="templateDialogVisible = false" class="cancelButton"
        >取消</el-button
        >
        <el-button :size="size" type="primary" @click.native="saveTemplate" class="searchButton"
        >确定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog :visible.sync="mutexPromotionVisible" title="互斥活动详情"  :close-on-click-modal="false">
      <div>
        <el-table :data="mutexPromotionList" ref="multipleTable" :row-class-name="tableRowClassName"  :size="size">
          <el-table-column prop="promotionCode" width="280" label="互斥活动编码" sortable align="center"></el-table-column>
          <el-table-column prop="promName"  width="150" label="互斥活动名称" align="center"></el-table-column>
          <el-table-column prop="goodsCategory"  width="360" label="互斥活动时间" align="center">
            <template slot-scope="scope">
                <span>{{scope.row.startTime}} - {{scope.row.endTime}}</span>
              </template>
          </el-table-column>
          <el-table-column prop="storeName" label="活动状态" align="center" width="200">
            <template slot-scope="scope">
              <span class="color333 font18" v-if="scope.row.status == 0">待提交</span>
              <span class="color333 font18" v-else-if="scope.row.status == 1">待提交</span>
              <span class="color333 font18" v-else-if="scope.row.status == 2">待审核</span>
              <span class="color333 font18" v-else-if="scope.row.status == 3">未开始</span>
              <span class="color333 font18" v-else-if="scope.row.status == 4">审核不通过</span>
              <span class="color333 font18" v-else-if="scope.row.status == 5">进行中</span>
              <span class="color333 font18" v-else-if="scope.row.status == 6">已过期</span>
              <span class="color333 font18" v-else-if="scope.row.status == 7">已关闭</span>
              <span class="color333 font18" v-else-if="scope.row.status == 8">已结束</span>
              <span class="color333 font18" v-else-if="scope.row.status == 9">活动草稿</span>
            </template>
          </el-table-column>
          <el-table-column prop="creatorName" label="创建人" align="center" width="200"></el-table-column>
          <el-table-column prop="deptName"  label="创建组织" align="center" width="200"></el-table-column>
        </el-table>
        <!--分页栏-->
        <div class="toolbar t_r">
          <el-pagination
            @size-change="mutexPromotionListSizeChange"
            @current-change="mutexPromotionListCurrentChange"
            :current-page="mutexPromotionForm.start"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="mutexPromotionForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="mutexPromotionListTotal"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer t_c">
        <el-button type="primary" plain :size="size" @click.native="mutexPromotionVisible = false" class="searchButton">关闭</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
  import KtButton from "@/views/Core/KtButton";
  import { format } from "@/utils/datetime";
  import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
  import { darkmagenta } from "color-name";
  import { quillEditor } from "vue-quill-editor";
  import TreeSelect from "@/views/Core/TreeSelect";
  import "quill/dist/quill.core.css";
  import "quill/dist/quill.snow.css";
  import "quill/dist/quill.bubble.css";
  import { getAllRow, changeChild, changeParent } from "@/assets/js/tableTree.js";
  import {
    singleFrontPromTypesRadio,
    chanelCodesRadio,
    proPlatformRadio,
    proUserTypeRadio,
    proMemberTypeRadio,
    proMemberLevelRadio
  } from "@/market/dict/marketDict";
  import marketRequest from "@/market/request/marketRequest";
  const channelArr = ["bbc"];
  const channelArr1 = ["APP端", "PC端", "微信"];
  const channelArr2 = ["新用户", "老用户"];
  const channelArr3 = ["普通会员"];
  const channelArr4 = ["注册用户", "VIP会员", "金卡"];
  export default {
    name: "Tab",
    components: {
      KtButton,
      TableColumnFilterDialog,
      quillEditor,
      TreeSelect
    },
    created: function() {
      //当前登录用户身份为母平台才获取子平台列表
      if (localStorage.getItem("deptType") && localStorage.getItem("deptType") == 0) {
        this.getChildList();
      }else{
        this.channelChange();
      }
      this.getTagList();
      this.getTagCategoryList();
      if (typeof this.$route.query.active != "undefined") {
        this.active = this.$route.query.active;
      }
    },
    data() {
      var checkParentAllocationScale = (rule, value, callback) => {
        let regPos = /^[0-9]([0-9]*)$/; // 非负整数
        if (regPos.test(value)) {
          if (Number.parseInt(value) >= 100) {
            callback(new Error("输入不能超过100"));
          }
          if (
            Number.parseInt(value) +
            Number.parseInt(this.filters.childAllocationScale) +
            Number.parseInt(this.filters.merchantAllocationScale) +
            Number.parseInt(this.filters.storeAllocationScale) !=
            100
          ) {
            callback(new Error("比例相加应等于100"));
          } else {
            this.$refs.filters.clearValidate("childAllocationScale");
            this.$refs.filters.clearValidate("merchantAllocationScale");
            this.$refs.filters.clearValidate("storeAllocationScale");
            callback();
          }
        } else {
          callback(new Error("请输入大于等于0并且不能超过100"));
        }
      };
      var checkChildAllocationScale = (rule, value, callback) => {
        let regPos = /^[0-9]([0-9]*)$/; // 非负整数
        if (regPos.test(value)) {
          if (Number.parseInt(value) >= 100) {
            callback(new Error("输入不能超过100"));
          }
          if (
            Number.parseInt(value) +
            Number.parseInt(this.filters.parentAllocationScale) +
            Number.parseInt(this.filters.merchantAllocationScale) +
            Number.parseInt(this.filters.storeAllocationScale) !=
            100
          ) {
            callback(new Error("比例相加应等于100"));
          } else {
            this.$refs.filters.clearValidate("parentAllocationScale");
            this.$refs.filters.clearValidate("merchantAllocationScale");
            this.$refs.filters.clearValidate("storeAllocationScale");
            callback();
          }
        } else {
          callback(new Error("请输入正整数"));
        }
      };
      var checkMerchantAllocationScale = (rule, value, callback) => {
        let regPos = /^[0-9]([0-9]*)$/; // 非负整数
        if (regPos.test(value)) {
          if (Number.parseInt(value) >= 100) {
            callback(new Error("输入不能超过100"));
          }
          if (
            Number.parseInt(value) +
            Number.parseInt(this.filters.parentAllocationScale) +
            Number.parseInt(this.filters.childAllocationScale) +
            Number.parseInt(this.filters.storeAllocationScale) !=
            100
          ) {
            callback(new Error("比例相加应等于100"));
          } else {
            this.$refs.filters.clearValidate("parentAllocationScale");
            this.$refs.filters.clearValidate("childAllocationScale");
            this.$refs.filters.clearValidate("storeAllocationScale");
            //this.$refs.filters.validateField('storeAllocationScale');
            callback();
          }
        } else {
          callback(new Error("请输入正整数"));
        }
      };
      var checkStoreAllocationScale = (rule, value, callback) => {
        let regPos = /^[0-9]([0-9]*)$/; // 非负整数
        if (regPos.test(value)) {
          if (Number.parseInt(value) >= 100) {
            callback(new Error("输入不能超过100"));
          }
          if (
            Number.parseInt(value) +
            Number.parseInt(this.filters.parentAllocationScale) +
            Number.parseInt(this.filters.merchantAllocationScale) +
            Number.parseInt(this.filters.childAllocationScale) !=
            100
          ) {
            callback(new Error("比例相加应等于100"));
          } else {
            this.$refs.filters.clearValidate("parentAllocationScale");
            this.$refs.filters.clearValidate("childAllocationScale");
            this.$refs.filters.clearValidate("merchantAllocationScale");
            //this.$refs.filters.validateField('parentAllocationScale');
            callback();
          }
        } else {
        callback(new Error("请输入正整数"));
      }
    };

    // var checkTagName = (rule, value, callback) => {
    //   var regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im,
    //     regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\]]/im;
    //   if (regEn.test(value) || regCn.test(value)) {
    //     callback(new Error("名称不能包含特殊字符"));
    //   }
    //   callback();
    // };
    // var checkOverlayAppNum = (rule, value, callback) => {
    //   var regEn = /^\+?[1-9][0-9]*$/;
    //   if (!regEn.test(value)) {
    //     callback(new Error("请输入正整数"));
    //   }
    //   callback();
    // };
    // var isNumber = (rule, value, callback) => {
    //   if (value === "") {
    //     return callback();
    //   } //这是用来判断如果不是必须输入的，则直接跳出
    //   const r = /^\+?[1-9][0-9]*$/; // 正整数
    //   // 如果判断不符合正则，则不是正整数不能提交
    //   if (!r.test(value)) {
    //     return callback(new Error("必须为正整数"));
    //     productForm;
    //   } else {
    //     // if (
    //     //   this.filters.parentAllocationScale != undefined &&
    //     //   this.filters.childAllocationScale != undefined &&
    //     //   this.filters.merchantAllocationScale != undefined &&
    //     //   this.filters.storeAllocationScale != undefined
    //     // ) {
    //     let countScale =
    //       Number(this.filters.parentAllocationScale) +
    //       Number(this.filters.childAllocationScale) +
    //       Number(this.filters.merchantAllocationScale) +
    //       Number(this.filters.storeAllocationScale);
    //
    //     if (countScale != 100) {
    //       return callback(new Error("加起来必须等于100%"));
    //     } else {
    //       this.$refs.filters.clearValidate("childAllocationScale");
    //       this.$refs.filters.clearValidate("merchantAllocationScale");
    //       this.$refs.filters.clearValidate("storeAllocationScale");
    //       this.$refs.filters.clearValidate("parentAllocationScale");
    //       return callback();
    //     }
    //     // }
    //     // return callback();
    //   }
    // };
    // var checkConditonValue = (rule, value, callback) => {
    //   var r = /^\d+\.?\d{0,2}$/; // 2位小数
    //   var r1 = /^\+?[1-9][0-9]*$/; // 正整数
    //   // 如果判断不符合正则，则不是正整数不能提交
    //   if (this.filters.frontPromType == 15 && !r.test(value)) {
    //     return callback(new Error("请输入数字(支持2位小数)"));
    //   }
    //   if (this.filters.frontPromType == 16 && !r1.test(value)) {
    //     return callback(new Error("必须为正整数"));
    //   }
    //   return callback();
    // };
    // return {
      // merchantProductTotalCount: 0,
      // deptType: localStorage.getItem("deptType"), //当前登录用户所属组织类型
      // 活动时间校验
      // timeCheck: {
      //   disabledDate: time => {
      //     if (this.promotionStartEndTime) {
      //       return (
      //         time.getTime() < Date.now() - 8.64e7 ||
      //         time.getTime() > new Date(this.promotionStartEndTime).getTime()
      //       );
      //     } else {
      //       return time.getTime() < Date.now() - 8.64e7;
      //     }
      //   }
      // },
      // };
      var checkTagName = (rule, value, callback) => {
        var regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im,
          regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\]]/im;
        if (regEn.test(value) || regCn.test(value)) {
          callback(new Error("名称不能包含特殊字符"));
        }
        callback();
      };
      var checkOverlayAppNum = (rule, value, callback) => {
        var regEn = /^\+?[1-9][0-9]*$/;
        if (!regEn.test(value)) {
          callback(new Error("请输入正整数"));
        }
        callback();
      };
      /**
       * 校验会员等级
       */
      var checkMemLevel = (rule, value, callback) => {
        //查看每个子平台是否都选中了
        let memberGradeList = this.memberGradeList;
        if(memberGradeList == null || memberGradeList.length < 1){
          return callback(new Error("会员等级不能为空"));
        }
        let flag = false;
        for(var i = 0; i< memberGradeList.length ; i++){
          if((memberGradeList[i].levelSelectList == null || memberGradeList[i].levelSelectList.length < 1 )&& !memberGradeList[i].checkAll){
            flag = true;
            break;
          }
        }
        if(flag){
          return callback(new Error("每个平台必须选中一个会员等级"));
        }
        return callback();
      };
      /**
       * 会员类型
       */
      var checkMemType = (rule, value, callback) => {
        if(this.selectMemTypes == null || this.selectMemTypes.length < 1){
          return callback(new Error("请选择会员类型"));
        }

        return callback();

      };
      var isNumber = (rule, value, callback) => {
        if (value === "") {
          return callback();
        } //这是用来判断如果不是必须输入的，则直接跳出
        const r = /^\+?[1-9][0-9]*$/; // 正整数
        // 如果判断不符合正则，则不是正整数不能提交
        if (!r.test(value)) {
          return callback(new Error("必须为正整数"));
          productForm;
        } else {
          // if (
          //   this.filters.parentAllocationScale != undefined &&
          //   this.filters.childAllocationScale != undefined &&
          //   this.filters.merchantAllocationScale != undefined &&
          //   this.filters.storeAllocationScale != undefined
          // ) {
          let countScale =
            Number(this.filters.parentAllocationScale) +
            Number(this.filters.childAllocationScale) +
            Number(this.filters.merchantAllocationScale) +
            Number(this.filters.storeAllocationScale);
          if (countScale != 100) {
            return callback(new Error("加起来必须等于100%"));
          } else {
            this.$refs.filters.clearValidate('childAllocationScale');
            this.$refs.filters.clearValidate('merchantAllocationScale');
            this.$refs.filters.clearValidate('storeAllocationScale');
            this.$refs.filters.clearValidate('parentAllocationScale');
            return callback();
          }
          // }
          // return callback();
        }
      };
      var checkConditonValue = (rule, value, callback) => {
        var r = /^\d+\.?\d{0,2}$/; // 2位小数
        var r1 = /^\+?[1-9][0-9]*$/; // 正整数
        // 如果判断不符合正则，则不是正整数不能提交
        if (this.filters.frontPromType == 15 && !r.test(value)) {
          return callback(new Error("请输入数字(支持2位小数)"));
        }
        if (this.filters.frontPromType == 16 && !r1.test(value)) {
          return callback(new Error("必须为正整数"));
        }
        return callback();
      };
      /**
       * 新老用户
       */
      var checkUserType = (rule, value, callback) => {
        if(this.selectUserType == null || this.selectUserType.length < 1){
          return callback(new Error("请选择新老用户"));
        }
        return callback();
      };
      return {
        channelOption:[],
        merchantFormRules: {
          // orgNumber: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // name: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        storeFormRules: {
          // storename: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // storecode: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // merchantName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        merchantSearchFormRules: {
          // orgNumber: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // merchantName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        storeSearchFormRules: {
          // storecode: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // storename: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        productFormRules: {
          // goodsName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // thirdSpuId: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // goodsCategory: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // storeName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        merchantProductSearchFormRules: {
          // mpCode: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // mpName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
          // categoryName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        },

        auditCount: 0,
        merchantProductTotalCount: 0,
        deptType: localStorage.getItem("deptType"), //当前登录用户所属组织类型
        // 活动时间校验
        timeCheck: {
          disabledDate: time => {
            if (this.promotionStartEndTime) {
              return (
                time.getTime() < Date.now() - 8.64e7 ||
                time.getTime() > new Date(this.promotionStartEndTime).getTime()
              );
            } else {
              return time.getTime() < Date.now() - 8.64e7;
            }
          }
        },
        storeSearchForm: {
          storename:"",
          storecode:"",
          promotionId: this.promotionId,
          merchantType: "2",
          pageNo: 1,
          pageSize: 10,
          orderBys: {
            f: "create_time",
            s: "desc"
          }
        },
        searchMerchantFlag: false,
        searchStoreFlag: false,
        merchantSearchForm: {
          merchantName: null,
          orgNumber:null,
          promotionId: this.promotionId,
          merchantType: "1",
          pageNo: 1,
          pageSize: 10,
          orderBys: {
            f: "create_time",
            s: "desc"
          }
        },
        templateDataForm: {
          templateName: null
        },
        templateDataFormRules: {
          templateName: [
            { required: true, message: "请输入模板名称",trigger:"blur" },
            { required: true, message: "请输入模板名称",trigger:"change" },
            { max: 60, message: "模板名称最多60字符", trigger: "blur" },
            { max: 60, message: "模板名称最多60字符", trigger: "change" }
          ]
        },
        templateDialogVisible: false,
        filtersRules: {
          conditionValue: [
            { required: true, validator: checkConditonValue, trigger: "blur" }
          ],
          overlayAppNum: [{ validator: checkOverlayAppNum, trigger: "change" }],
          parentAllocationScale: [
            { required: true, validator: isNumber, trigger: "blur" }
          ],
          childAllocationScale: [
            { required: true, validator: isNumber, trigger: "blur" }
          ],
          merchantAllocationScale: [
            { required: true, validator: isNumber, trigger: "blur" }
          ],
          storeAllocationScale: [
            { required: true, validator: isNumber, trigger: "blur" }
          ],
          promName: [
            { required: true, message: "请输入活动名称" },
            { min: 3, max: 60, message: "长度在 3 到 60 个字符", trigger: "blur" }
          ],
          promotionStartEndTime: [
            { required: true, message: "请选择时间", trigger: "blur" }
          ],
          frontPromType: [
            { required: true, message: "请选择促销类型", trigger: "blur" }
          ],
          mainGiftSameFlag: [
            { required: true, message: "请选择主赠相同", trigger: "blur" }
          ],
          overlayAppFlag: [
            { required: true, message: "请选择是否叠加应用", trigger: "blur" }
          ],
          // promotionRules: [
          //   { required: true, message: '请设置优惠设置', trigger: 'blur' },
          // ],
          parcelsFlag: [
            { required: true, message: "请选择是否包邮", trigger: "blur" }
          ],
          costAllocationFlag: [
            { required: true, message: "请选择是否分摊", trigger: "blur" }
          ],
          channelCodes: [
            { required: true, message: "请选择使用渠道", trigger: "blur" }
          ],
          //proUserType: [{ required: true, message: "用户类型", trigger: "blur" }],
          selectUserType: [{ required: true, validator: checkUserType, trigger: "change" }],
          levelSelectList: [{ required: true , validator: checkMemLevel, trigger: "blur"}] ,
          selectMemTypes: [{required: true, validator: checkMemType , trigger: "blur"}]
        },
        merchantProductSearchForm: {
          promotionId: null,
          merchantId: null,
          storeId: null,
          mpCode: null,
          mpName: null,
          categoryName: null,
          start: 1,
          limit: 10
        },
        searchMerchantProductFlag: false,
        giftNode: null,
        giftCouponsTableData: [],
        giftCouponsAddFlag: false,
        addTagDialogFormVisible: false,
        addTagForm: {
          categoryId: null,
          tagName: null
        },
        formLabelWidth: "120px",
        tagCategoryList: [
          {
            id: 1,
            categoryName: "标签分类"
          }
        ],
        addTagRules: {
          categoryId: [
            { required: true, message: "请选择标签分类", trigger: "change" }
          ],
          tagName: [
            { required: true, message: "请输入标签名称", trigger: "blur" },
            {
              min: 1,
              max: 30,
              message: "长度在 1 到 30 个字符",
              trigger: "blur"
            },
            { trigger: "blur", validator: checkTagName }
          ]
        },
        giftCouponsForm: {
          activityEndTime: null,
          activityStartTime: null,
          couponAmountStart: null,
          couponAmountEnd: null,
          couponName: null,
          couponId: null,
          start: 1,
          limit: 10
        },
        channelList: [],
        tagList: [],
        giftNodes: [
          { code: 1, name: "订单已支付" },
          { code: 2, name: "订单已收货" },
          { code: 3, name: "订单已完成" }
        ],
        mutexDetailDialogVisible: false,
        mutexPromotionTable: [],
        giftAddFlag: true,
        labelPosition: "right",
        // setep3--start
        productPromotionListObject: { productPromotionList: [] },
        productAddSelection: [],
        giftProductAddSelection: [],
        giftCouponsAddSelection: [],
        tableDataTwo: [],
        merchantProductTableData: [],
        merchantProductTableDataTotal: 0,
        dialogVisibleTwo: false,
        tabsIndex: "first",
        giftProductTableDataSize: 0,
        seeGiftProductTableDataSize: 0,
        giftCouponsTableDataSize: 0,
        giftProductTableData: [],
        productForm: {
          start: 1,
          limit: 10,
          goodsName: null,
          storeName: null,
          thirdSpuId: null,
          goodsCategory: null,
          storeIds: [],
          barCode: "",
          chineseName: "",
          code: ""
        },
        giftProductForm: {
          start: 1,
          limit: 10,
          productName: "",
          productNo: "",
          barCode: "",
          goodsName: "",
          thirdSkuId: "",
          goodsCategory:""
        },
        seeGiftProductForm: {
          start: 1,
          limit: 10,
          mpCode: null,
          mpName: null,
          goodsCategory:null
        },
        // setep3--end
        adminDataForm: {
          auditRemark: null
        },
        adminDataFormRules: {
          auditRemark: [
            { required: true, message: "审核意见不能为空", trigger: "blur" }
          ]
        },
        dialogVisibleAdmin: false,
        shenhe: 0,
        size: "small",
        editDialogVisible: false,
        editDialogVisible2: false,
        url: "./static/shop.png",
        url2: "./static/shop2.png",
        content: null,
        editorOption: {},
        size: "small",
        productVisible: false,
        giftProductVisible: false,
        giftCouponsVisible: false,
        uploadVisible: false,
        operation: false, // true:商品导入, false:下载模板
        activeName: 0,
        setUp: false,
        search: false,
        filters: {
          labelId: null,
          id: null,
          promName: null,
          promType: 8, //赠送类促销
          frontPromType: 15,
          foldingFlag: 1,
          overLimitRule: 2,
          channelCodes: null,
          proPlatform: [1],
          proUserType: null,
          proMemberType: [1],
          proMemberLevel: [2],
          createMerchantId: 11,
          contentType: 1,
          overlayAppFlag: 0,
          overlayAppNum: null,
          giftType: 1,
          status: 9,
          // "creator":1,
          // "creatorName":"wys",
          // "updator":1,
          // "updatorName":"wys",
          rejectCouponsFlag: 0,
          parcelsFlag: 0,
          description: "",
          promotionRules: [
            { conditionValue: null, contentValue: null, id: null, level: 1 }
          ],
          mainGiftSameFlag: 1,
          costAllocationFlag: 1,
          parentAllocationScale: null,
          childAllocationScale: null,
          merchantAllocationScale: null,
          storeAllocationScale: null,
          templateFlag: 1,
          templateName: null,
          storeArea: -1,
          userArea: -1,
          promotionStartEndTime: []
        },
        editLoading: false,
        dataForm: {},
        modalShow: 1,
        multipleSelection: [],
        batchDeleteSelection: [],
        repelSelection: [],
        addSelection: [],
        businessList: [{ id: "001", name: "张小二服饰", type: "自营商家" }],
        shopList: [{ id: "161616", name: "张小二bbc店铺", type: "直营" }],
        tableData: [
          {
            id: 1912250010887324,
            productName: "新供应商001",
            unit: "件",
            shopName: "张小二服饰",
            price: 1.2,
            markdown: 1,
            shopLimit1: 100,
            shopLimit2: 100,
            shopLimit3: 100
          },
          {
            id: 1912250010887323,
            productName: "新供应商002",
            unit: "件",
            shopName: "张小二服饰",
            price: 1.3,
            markdown: 1,
            shopLimit1: 100,
            shopLimit2: 100,
            shopLimit3: 100
          }
        ],
        active: this.$route.query.auth==null ? 1 :this.$route.query.auth,
        radio1: 3,
        radio2: 3,
        radio3: 3,
        radio4: 3,
        radio5: 3,
        shopList: [],
        businessList: [],
        checkAll: false,
        checkAll1: false,
        checkAll2: true,
        checkAll3: false,
        checkAll4: false,
        checkedCities: [110001],
        checkedCities1: ["APP端", "PC端", "微信"],
        checkedCities2: ["新用户", "老用户"],
        checkedCities3: ["普通会员"],
        checkedCities4: ["注册用户", "VIP会员", "金卡"],
        frontPromTypesRadios: singleFrontPromTypesRadio,
        chanelCodesRadios: chanelCodesRadio,
        proPlatformRadios: proPlatformRadio,
        proUserTypeRadios: proUserTypeRadio,
        proMemberTypeRadios: proMemberTypeRadio,
        proMemberLevelRadios: proMemberLevelRadio,
        cities: channelArr,
        cities1: channelArr1,
        cities2: channelArr2,
        cities3: channelArr3,
        cities4: channelArr4,
        isIndeterminate: true,
        isIndeterminate1: true,
        isIndeterminate2: true,
        isIndeterminate3: true,
        isIndeterminate4: true,
        giftRuleTable: [{ conditionValue: null }],
        giftItemTable: [],
        currentRule: {},
        options: [
          {
            value: "1",
            label: "京东直营"
          },
          {
            value: "2",
            label: "淘宝旗舰"
          },
          {
            value: "3",
            label: "良品铺子1店"
          }
        ],
        value5: [],
        options2: [
          {
            value: "1",
            label: "良品铺子"
          }
        ],
        value6: [],
        isClearable: true, // 可清空（可选）
        isAccordion: true, // 可收起（可选）
        valueId: 20, // 初始ID（可选）
        props: {
          // 配置项（必选）
          value: "id",
          label: "name",
          children: "children"
          // disabled:true
        },
        // 选项列表（必选）
        list: [
          { id: 2, parentId: 0, name: "居家生活", rank: 1 },
          { id: 4, parentId: 0, name: "数码家电", rank: 1 },
          { id: 5, parentId: 0, name: "母婴保健", rank: 1 },
          { id: 6, parentId: 0, name: "美食酒水", rank: 2 },
          { id: 7, parentId: 0, name: "个护清洁", rank: 2 },
          { id: 9, parentId: 0, name: "好物甄选", rank: 2 },

          { id: 101, parentId: 2, name: "个护健康", rank: 3 },
          { id: 102, parentId: 2, name: "3C数码", rank: 4 },
          { id: 103, parentId: 2, name: "汽车用品", rank: 5 },
          { id: 202, parentId: 101, name: "按摩电器", rank: 5 },
          { id: 203, parentId: 101, name: "个护美容", rank: 5 }
        ],

        //第一步添加成功赋值
        //外部赋值-----------------start
        promotionId: null,
        auth: 0,
        tagCategoryList: [],
        //外部赋值-----------------start

        promotion: {
          //促销id
          id: "",
          promotionId: "1",
          merchantType: "1"
        },
        pomotionListObject: { pomotionList: [] },
        // pomotionList:[
        //   {
        //   // id:"0",
        //   promotionId:"0",
        //   merchantId:"0",
        //   merchantType:0,
        //   merchantName:"",
        //   storeId:"0",
        //   // createTime:"2020-01-15 11:38:41",
        //   // creator:"0",
        //   // creatorName:"",
        //   // updateTime:"2020-01-15 11:38:41",
        //   // updator:"0",
        //   // updatorName:""
        // }
        // ],
        mainMerchantForm: {
          promotionId: this.promotionId,
          merchantType: "1",
          pageNo: 1,
          pageSize: 10,
          orderBys: {
            f: "create_time",
            s: "desc"
          }
        },
        mainMerchantTableDataTatol: 0,
        //---------------------------商家------------------------------------------------start
        merchantForm: {
          start: 1,
          limit: 10,
          name: null,
          orgNumber: null,
          merchantType:null

        },
        merchantFormStore: {
          start: 1,
          limit: 10
        },
        merchantTableDataTatol: 0,
        merchantTableDataTatolStore: 0,
        merchantTableData: [],
        //选择的商家列表
        merchantTableData2: [],
        promotionStoreTableData: [],
        //---------------------------商家------------------------------------------------end
        storeForm: {
          start: 1,
          limit: 10,
          merchantIds: "",
          storename: "",
          storecode: "",
          orgNumber: "",
          merchantName: "",
          storeType:''

        },

        mainStoreMerchantForm: {
          promotionId: this.promotionId,
          merchantType: "2",
          pageNo: 1,
          pageSize: 10,
          orderBys: {
            f: "create_time",
            s: "desc"
          }
        },
        storeTableDataTatol: 0,
        storeTableData: [],
        //选择店铺
        storeTableData2Tatol: 0,
        storeTableData2: [],
        //选择店铺
        addSelectionStoreTableData2: [],
        merchantTableData2Selection: [],
        merchantTableData2SelectionIndex: 0,
        storeTableDataSelection: [],
        storeTableDataSelectionIndex: 0,

        // -----------------------------------商品开始属性-----------------------------------start

        productTableDataTotal: 0,
        productTableData: [],
        productEditLoading: false,
        giftProductEditLoading: false,
        giftCouponsEditLoading: false,
        productPromotion: {
          //促销id
          promotionId: "1"
        },

        mainProductForm: {
          promotionId: this.promotionId,
          start: 1,
          limit: 10,
          orderBys: {
            f: "create_time",
            s: "desc"
          }
        },

        merchantProductTableDataTotal: 0,

        merchantProductTableDataMutex: [
          {
            id: 1912250010887324,
            promotionId: 2001100000003832,
            mpCode: 2001100000003832,
            productName: "新供应商001",
            unit: "件",
            merchantName: "张小二服饰",
            price: 1.2,
            contentType: 1,
            channelMerchantLimit: 100,
            channelStoreLimit: 100,
            channelIndividualLimit: 100,
            orderLimit: 100
          },
          {
            id: 1912250010887323,
            promotionId: 2001100000003832,
            mpCode: 200110000000384,
            productName: "新供应商002",
            unit: "件",
            merchantName: "张小二服饰",
            price: 1.2,
            contentType: 1,
            channelMerchantLimit: 10,
            channelStoreLimit: 10,
            channelIndividualLimit: 10,
            orderLimit: 1
          }
        ],

        merchantProductTableDataMutexTotal: 0,
        channelList: [], //渠道Tree List
        channlProps: {
          children: "children",
          label: "childName"
        },

        // -----------------------------------商品结束属性-----------------------------------end

        productStatusTabs: "1" ,   //商品tabs

        mutexMerchantProductTotalCount: 0 ,   //互斥Sku总条数
        mutexProductList: [] ,                //互斥商品List
        mutexProductForm: {
            start : 1,
            limit: 10,
            promotionId: this.promotionId,
            mutexFlag:1,//互斥标识
        },
        mutexProductTotal: 0,                 //互斥分页总条数
        showButtons:true,                     //功能按钮
        mutexPromotionList:[],                //查看详情弹窗
        mutexPromotionListTotal:0,
        mutexPromotionVisible:false,
        mutexPromotionForm:{
          promType: 1,
          start:1,
          limit:10,
        },

        isAllChecked: false,//全选
        isIndeterminateCheck: false,//全选 checkbox 的不确定状态
        allData: [],//全选 操作数据

        isAllProductChecked: false,//全选
        isIndeterminateProductCheck: false,//全选 checkbox 的不确定状态
        allProductData: [],//全选 操作数据

        //会员等级 会员类型
        memberGradeList: [],
        reloadMemLevel: true,

        //会员类型
        memTypeCheckAll: true,
        selectMemTypes:[1,2],
        memTypeIsIndeterminate: false,
        userTypeCheckAll: true,
        selectUserType:[1,2],
        userTypeIsIndeterminate: false,
      };
    },
    methods: {
      queryChannelListOther: function() {
      var this_ = this;
      this.utils.request.queryChannelListOther({}, function(res) {
        if (res.code == "0000") {
          this_.channelOption = res.data;
        }
      });
    },
      //新老用户
      handleCheckAllUserTypeChange(val) {
        this.selectUserType = val ? [1,2] : [];
        this.userTypeIsIndeterminate = false;
      },
      handleCheckedUserTypeChange(value) {
        let checkedCount = value.length;
        this.userTypeCheckAll = checkedCount === 2;
        this.userTypeIsIndeterminate = checkedCount > 0 && checkedCount < 2;
      },
      getUuid() {
        var s = [];
        var hexDigits = "0123456789abcdef";
        for (var i = 0; i < 36; i++) {
          s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
        s[8] = s[13] = s[18] = s[23] = "-";

        var uuid = s.join("");
        return uuid;
      },
      //使用渠道选中时触发
      channelChange(callback){
        let deptNodeList = [];
        let deptIds = [];
        if(this.deptType == 0){
          deptNodeList = this.$refs.channelTree.getCheckedNodes();
          deptIds = deptNodeList.map((item,index) =>{
            return item.deptId;
          })
          if(deptIds.indexOf("179") == -1){
            deptIds.unshift("179");
            deptNodeList.unshift({"deptId":179,"childName":"卡奥斯运营中心","id":179})
          }
        }else{
          //查询子平台信息
          let deptId = localStorage.getItem("deptId");
          deptIds.push(deptId);
          let userInfo = JSON.parse(localStorage.getItem("user"));
          deptNodeList.push({deptId:userInfo.deptId,"childName":userInfo.deptName,"id":userInfo.businessId})
        }

        this.utils.request.listMemberGradeForMarket({"deptIds": deptIds.join(",")},res=>{
          if(res.code == '0000'){
            let levelList = res.data;
            let restLevelInfo =  [];
            //如果存在排除重新赋值
            this.memberGradeList.forEach(levelItem=>{
              let levelInfo = levelList.find(function(level) {
                return levelItem.deptId == level.deptId;
              })
              if(levelInfo != undefined){
                restLevelInfo.push(levelItem);
              }
            })
            //遍历
            this.memberGradeList = restLevelInfo;
            for(let deptInfo of deptNodeList){
              let levelItem = this.memberGradeList.find(function(level) {
                return deptInfo.deptId == level.deptId;
              })
              if(levelItem != undefined){
                continue;
              }
              //如果不勾选子平台 删除已有子平台

              let levelInfo = levelList.find(function(level) {
                return level.deptId == deptInfo.deptId;
              })
              if(levelInfo == undefined){
                this.memberGradeList.push({ deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,checkAll: true, isIndeterminate: false,  levelSelectList: [], levelList:[]})
              }else{
                //添加数据
                let selectLevelIds = levelInfo.mememberGradeResponseList.map((item,index) =>{
                  return item.id;
                })
                levelInfo.mememberGradeResponseList.forEach(item=>{
                  item.key = this.getUuid();
                })
                this.memberGradeList.push({deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,  levelSelectList: selectLevelIds,  checkAll: true , isIndeterminate: false , levelList:levelInfo.mememberGradeResponseList})
              }
            }
          }else{
            this.memberGradeList = [];
          }
          this.$nextTick(()=>{
            if(callback != undefined){
              callback();
            }
          })
        })
        // this.getMemLevelList(deptIds.join(","))
      },

      //会员类型
      handleCheckAllMemTypeChange(val) {
        this.selectMemTypes = val ? [1,2] : [];
        this.memTypeIsIndeterminate = false;
      },
      handleCheckedMemTypeChange(value) {
        let checkedCount = value.length;
        this.memTypeCheckAll = checkedCount === 2;
        this.memTypeIsIndeterminate = checkedCount > 0 && checkedCount < 2;
      },

      //会员等级
      handleMemLevelCheckAllChange(index,checked){
        if(!checked){
          //取消全部
          let memberSelectGrade = this.memberGradeList[index];
          memberSelectGrade.checkAll = false;
          memberSelectGrade.isIndeterminate = false;
          memberSelectGrade.levelSelectList = [];
          // this.$s
          this.$set(this.memberGradeList,index,memberSelectGrade);

        }else{
          //选中全部
          let ids = [];
          this.memberGradeList[index].levelList.forEach(item=>{
            ids.push(item.id)
          })
          let memberSelectGrade = this.memberGradeList[index];
          memberSelectGrade.checkAll = true;
          memberSelectGrade.isIndeterminate = false;
          memberSelectGrade.levelSelectList = ids;
          // this.$s
          this.$set(this.memberGradeList,index,memberSelectGrade);
        }
      },
      memLevelChange(index, levelList){
        //查看当前子平台是否全选
        let levelSelectList = this.memberGradeList[index].levelSelectList;
        if(levelSelectList == null || levelSelectList.length < 1){
          //没有选中子级
          let memberSelectGrade = this.memberGradeList[index];
          memberSelectGrade.checkAll = false;
          memberSelectGrade.isIndeterminate = false;
          memberSelectGrade.levelSelectList = [];
          // this.$s
          this.$set(this.memberGradeList,index,memberSelectGrade);
          return;
        }
        let noSelectIds = [];
        levelList.forEach(item=>{
          if(levelSelectList.indexOf(item.id) == -1){
            //存在
            noSelectIds.push(item.id);
          }
        })

        if(noSelectIds.length < 1){
          //全选
          let ids = [];
          this.memberGradeList[index].levelList.forEach(item=>{
            ids.push(item.id)
          })
          let memberSelectGrade = this.memberGradeList[index];
          memberSelectGrade.checkAll = true;
          memberSelectGrade.isIndeterminate = false;
          memberSelectGrade.levelSelectList = ids;
          this.$set(this.memberGradeList,index,memberSelectGrade);
        }else{
          //没有全选
          let ids = [];
          let memberSelectGrade = this.memberGradeList[index];
          memberSelectGrade.checkAll = false;
          memberSelectGrade.isIndeterminate = true;
          this.$set(this.memberGradeList,index,memberSelectGrade);
        }


      },

      saveTemplateDialog(){
        if (this.$refs['templateDataForm'] != undefined) {
          this.$refs['templateDataForm'].resetFields();
        }
        this.templateDialogVisible = true;
      },

      changeSearchMerchantProductFlag(){
        this.searchMerchantProductFlag = !this.searchMerchantProductFlag;
        this.resetForm("merchantProductSearchForm");
      },
      getPromotionStoreTableData(){
        let this_ = this;
        let param = {"promotionId":this.promotionId,"merchantType":2,"pageNo":1, "pageSize":100000};
        this.utils.request.promotionMerchantList(param, res => {
          if (res.code == "0000") {
            this_.promotionStoreTableData = res.data.list.map((ele, index) => {
              let promotionStore = {};
              promotionStore.id = ele.storeId;
              promotionStore.name = ele.storename;
              return promotionStore;
            });
          }
        });
      },
      /**
     * 查询互斥商品
     */
    getMutexProductList() {
      var this_ = this;
      this.mutexProductForm.promotionId = this.promotionId;
      marketRequest.getProductListV3(this.mutexProductForm, res => {
        if (res.code == "0000") {
          this_.mutexProductList = res.data.rows;
          this_.mutexProductTotal = res.data.total;
          this_.mutexMerchantProductTotalCount = res.data.totalCount;
          //操作数据
          this_.allData = getAllRow(this_.mutexProductList, []);
          this_.isAllChecked = false;
          this_.isIndeterminateCheck = false;
        }
      });
    },
    /**
     * 每页条数改变触发
     */
    handleSizeChangeMutexProductList(val){
      this.mutexProductForm.limit = val;
      this.mutexProductForm.start = 1;
      this.getMutexProductList();
    },
    /**
     * 换页刷新
     */
    handleCurrentChangeMutexProductList(val){
      this.merchantProductSearchForm.start = val;
      this.getMutexProductList();
    },

    /**
     * 互斥商品重新添加
     */
    renewAdd(row){
      let that = this;
      let param = {};
      var productIdList = [];
      param.promotionId = row.promotionId;
      param.promotionType = 1;

      if(row.typeOfProduct == '10'){
          //spu
          row.children.forEach(item=>{
            productIdList.push(item.id);
          })
      }else if(row.typeOfProduct == '20'){
        productIdList.push(row.id);
      }

      param.productIdList = productIdList;
      this.utils.request.renewAddMutexProduct(param,res=>{
        if(res.code=='0000'){
          that.getMutexProductList();
          that.getProductListV2(0, null);

          let data = res.data;
          if(data.businessCode == '0001'){
            this.$message({message: data.businessMsg, type: "success"});
          }else if(data.businessCode == '0002'){
            this.$message({message:data.businessMsg, type: "error"})
          }else if(data.businessCode == '0003'){
            this.$alert(data.businessMsg, '提示', {
              confirmButtonText: '知道了',
              callback: action => {}
            });
          }

        }
      });
    },

    /**
     * 批量重新添加选择数据
     */
    batchRenewAddSelectionChange(val) {
      this.batchRenewAddSelection = val;
    },

    /**
     * 批量重新添加
     */
    batchRenewAdd(){
      //
      let that = this;
      let param = {};
      var productIdList = [];
      param.promotionId = this.promotionId;
      param.promotionType = 1;
      this.allData.forEach(function(item,index,array){
        if(item.typeOfProduct == '20' && item.isCheck){
          productIdList.push(item.id);
        }
      });
      if (productIdList.length < 1) {
        this.$message({ message: "未选择重新添加条目", type: "error" });
        return;
      }
      param.productIdList = productIdList;
      this.utils.request.renewAddMutexProduct(param,res=>{
        if(res.code=='0000'){
          that.getMutexProductList();
          that.getProductListV2(0, null);

          let data = res.data;
          if(data.businessCode == '0001'){
            this.$message({message: data.businessMsg, type: "success"});
          }else if(data.businessCode == '0002'){
            this.$message({message:data.businessMsg, type: "error"})
          }else if(data.businessCode == '0003'){
            this.$alert(data.businessMsg, '提示', {
              confirmButtonText: '知道了',
              callback: action => {}
            });
          }
        }
      });
    },
    /**
     * 生效商品 互斥商品tab选中触发
     */
    productTabs(tab){
      if(tab.index==0){
        this.showButtons = true;
      }else{
        this.showButtons = false;
      }
    },
    /**
     * 互斥商品查看详情
     */
    getMutexInfo(row){
      let that = this;
      this.mutexPromotionForm.start = 1;
      this.mutexPromotionForm.limit = 10;
      this.mutexPromotionForm.promotionId = this.promotionId;
      this.mutexPromotionForm.promotionMerchantProductId = row.id;
      this.getPromotionMutexListByProductId();
    },
    getPromotionMutexListByProductId(){
      let that = this;
      this.utils.request.getPromotionMutexListByProductId(this.mutexPromotionForm,res=>{
        if(res.code=='0000'){
            that.mutexPromotionList = res.data.rows;
            that.mutexPromotionListTotal = res.data.total;
            that.mutexPromotionVisible = true;
        }
      });
    },

    /**
     * 每页条数改变触发
     */
    mutexPromotionListSizeChange(val){

      this.mutexPromotionForm.limit = val;
      this.mutexPromotionForm.start = 1;
      this.getPromotionMutexListByProductId();
    },
    /**
     * 换页刷新
     */
    mutexPromotionListCurrentChange(val){

      this.mutexPromotionForm.start = val;
      this.getPromotionMutexListByProductId();
    },



      resetPromotionRule(start){
        for (let i = this.filters.promotionRules.length-1; i>=0; i--) {
          if(start == 1 && i == 0){

          }else{
            this.removePromotionRuleSet(i, this.filters.promotionRules[i]);
          }
        }
        if(this.filters.promotionRules.length == 0){
          this.filters.promotionRules.push({ conditionValue: null, contentValue: null, id: null, level: 1 })
        }
        this.$refs.filters.clearValidate("promotionRules.0.conditionValue");
      },
      checkGiftProductLimits(row){
        let regPos = /^[1-9]([0-9]*)$/; // 非负整数
        //upgradeAmount //换购价
        // channelStoreLimit
        // individualLimit
        var priceReg = /^\d+\.?\d{0,2}$/; // 2位小数
        if(!row.upgradeAmount){
          this.$message({ message: "请输入商品换购价", type: "error" });
          return false;
        }
        if(!priceReg.test(row.upgradeAmount)){
          this.$message({ message: "换购价请输入数字(支持2位小数)", type: "error" });
          return false;
        }
        if(Number(row.upgradeAmount) > Number(row.salePrice)){
          this.$message({ message: row.upgradeAmount + "不能大于 " + row.salePrice, type: "error" });
          return false;
        }
        if(row.channelStoreLimit && !regPos.test(row.channelStoreLimit)){
          this.$message({ message: "请输入正整数-店铺限购", type: "error" });
          return false;
        }
        if(row.individualLimit && !regPos.test(row.individualLimit)){
          this.$message({ message: "请输入正整数-个人限购", type: "error" });
          return false;
        }
        if(Number(row.channelStoreLimit) > row.stock){
          this.$message({ message: "店铺限购不能大于库存", type: "error" });
          return false;
        }
        if(Number(row.individualLimit) > row.stock){
          this.$message({ message: "个人限购不能大于库存", type: "error" });
          return false;
        }
        if(Number(row.individualLimit) > Number(row.channelStoreLimit)){
          this.$message({ message: "个人限购不能大于店铺限购", type: "error" });
          return false;
        }
        return true;
      },
      getPromotionDetail(promotionId) {
        //获取促销基本信息详情
        let params = { id: promotionId },
          _this = this;
        this.utils.request.promotionDetailById(params, res => {
          if (res.code == "0000") {
            _this.filters.id = res.data.id;
            _this.filters.promType = res.data.promType;
            _this.filters.promName = res.data.promName;
            _this.filters.frontPromType = res.data.frontPromType;
            _this.filters.foldingFlag = res.data.foldingFlag;
            _this.filters.overLimitRule = res.data.overLimitRule;
            _this.filters.description = res.data.description;
            _this.filters.channelCodes = res.data.channelCodes;
            if (_this.deptType == 0) {
              _this.$refs.channelTree.setCheckedKeys(
                res.data.channelCodes.split(",").map(item => parseInt(item))
              );
            }
            _this.filters.proPlatform = (res.data.proPlatform + "").split("|");
            _this.filters.proUserType = res.data.proUserType + "";
            _this.filters.proMemberType = (res.data.proMemberType + "").split(
              "|"
            );
            _this.filters.proMemberLevel = (res.data.proMemberLevel + "").split(
              "|"
            );
            _this.filters.storeArea = -1; //(res.data.storeArea + "").split("|");
            _this.filters.userArea = -1; //(res.data.userArea + "").split("|");
            _this.filters.startTime = res.data.startTime;
            _this.filters.endTime = res.data.endTime;
            _this.filters.remark = res.data.remark;
            _this.filters.rejectCouponsFlag = res.data.rejectCouponsFlag;
            _this.filters.parcelsFlag = res.data.parcelsFlag;
            _this.filters.promotionRules = res.data.promotionRules.length == 0 ? [{ conditionValue: null, contentValue: null, id: null, level: 1 }] : res.data.promotionRules;
            _this.filters.mainGiftSameFlag = res.data.mainGiftSameFlag;
            _this.filters.costAllocationFlag = parseInt(
              res.data.costAllocationFlag
            );
            _this.filters.parentAllocationScale = res.data.parentAllocationScale;
            _this.filters.childAllocationScale = res.data.childAllocationScale;
            _this.filters.merchantAllocationScale =
              res.data.merchantAllocationScale;
            _this.filters.storeAllocationScale = res.data.storeAllocationScale;
            _this.filters.templateFlag = res.data.templateFlag;
            _this.filters.templateName = res.data.templateName;
            _this.filters.status = res.data.status;
            // _this.filters.promotionStartEndTime[0] = new Date(res.data.startTime);
            // _this.filters.promotionStartEndTime[1] = new Date(res.data.endTime);
            _this.$set(_this.filters, "promotionStartEndTime", [
              new Date(res.data["startTime"]),
              new Date(res.data["endTime"])
            ]);
            _this.filters.labelId = res.data.labelId != null ? Number(res.data.labelId) : null;
            _this.filters.overlayAppFlag = res.data.overlayAppFlag;
            _this.filters.freightType = res.data.freightType;
            _this.filters.freightValue = res.data.freightValue;
            _this.filters.freightReducedValue = res.data.freightReducedValue;
            let selectMemTypes = [];
            res.data.memTypes.split(",").forEach(item=>{
              selectMemTypes.push(Number(item));
            });
            _this.selectMemTypes = selectMemTypes;
            if(selectMemTypes.length < 2){
              this.memTypeIsIndeterminate = true;
              this.memTypeCheckAll = false;
            }
            //新老用户
            let selectUserType = [];
            res.data.proUserType.split(",").forEach(item=>{
              selectUserType.push(Number(item));
            });
            _this.selectUserType = selectUserType;
            if(selectUserType.length < 2){
              this.userTypeIsIndeterminate = true;
              this.userTypeCheckAll = false;
            }
            let promotionMemberGradeList = res.data.promotionMemberGradeList
            // 查询会员等级信息
            _this.$nextTick(()=>{
              let callback = function(){
                //回显选中的数据
                let memberGradeList = _this.memberGradeList;
                memberGradeList.forEach((item,index)=>{
                  let levelInfo = promotionMemberGradeList.find(function(level) {
                    return item.businessId == level.platformId;
                  });
                  if(levelInfo != null){
                    item.levelSelectList = levelInfo.levelCodeList;
                    //判断是否是全选
                    let checkFlagAll = false;
                    item.levelList.forEach(checkLevel=>{
                      let isCheckLevel = item.levelSelectList.find(function(level){
                        return level == checkLevel.id;
                      })
                      if(isCheckLevel == undefined){
                        checkFlagAll = true;
                        checkLevel.key = _this.getUuid();
                      }
                    })
                    if(checkFlagAll){
                      //没有全选
                      item.isIndeterminate = true;
                      item.checkAll = false;
                    }else{
                      //全选
                      item.isIndeterminate = false;
                      item.checkAll = true;
                    }

                  }else{
                    item.isIndeterminate = false;
                    item.checkAll = true;
                  }
                  //重新赋值 动态渲染
                  _this.$set(_this.memberGradeList,index, item)
                })
              }
              _this.channelChange(callback);
            })
          } else {
            alert("获取促销详情失败");
          }
        });
      },
      resetStoreForm() {
         //需要校验的keys
        let keys = ["storeType","merchantName","storecode","storename"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.storeForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("storeForm");
        this.storeFormFind();
      },
      resetSeeGiftProductForm() {
         //需要校验的keys
        let keys = ["goodsCategory","mpCode","mpName"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.seeGiftProductForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("seeGiftProductForm");
        this.checkPro(null);
      },
      resetGiftCouponsForm() {
         //需要校验的keys
        let keys = ["activityEndTime","activityStartTime","couponAmountEnd","couponAmountStart","couponId","couponName"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.giftCouponsForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("giftCouponsForm");
        this.giftCouponsFormFind();
      },
      resetGiftProductForm() {
         //需要校验的keys
        let keys = ["goodsCategory","thirdSkuId","goodsName"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.giftProductForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("giftProductForm");
        this.giftProductFormFind();
      },
      resetProductForm() {
        //需要校验的keys
        let keys = ["goodsCategory","thirdSpuId","goodsName","storeName"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.productForm,keys)
        if(!boo){
          return;
        }

        this.resetForm("productForm");
        this.productFormFind();
      },
      resetMerchantForm() {
         //需要校验的keys
        let keys = ["merchantType","name","orgNumber"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.merchantForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("merchantForm");
        this.merchantFormFind();
      },
      //获取子平台列表
      getChildList() {
        let this_ = this;
        let channel = { childName: "卡奥斯运营中心", id: "179", deptId:"179" };
        this.utils.request.queryChildList({}, res => {
          if (res.code == "0000" && res.data && res.data.length > 0) {
            channel.children = res.data;
            this.channelList.push(channel);
            if (this.promotionId == null) {
              this_.$nextTick(() => {
                this_.$refs.channelTree.setChecked("179", true, false);
                res.data.forEach(item => {
                  this_.$refs.channelTree.setChecked(item.id, true, false);
                });

                this_.channelChange();
              });
            }
          }
        });
      },
      addAllProduct() {
        let that_ = this;
        // this.productForm.storeIds = this.storeTableData.map((ele, index) => {
        //   return ele.id;
        // });
        let callback = function(res) {
          if (res.code == "0000") {
            that_.dialogVisibleTwo = false;
            // 成功查询本地促销商品
            that_.getProductListV2(0, null);
            that_.getMutexProductList();
          }
        };
        this.productForm.promotionId = this.filters.id;
        marketRequest.promotionMerchantProductAddAll(this.productForm, callback);
      },

      deleteGiftItem(id) {
        // this.$confirm("是否确认删除？", "提示", {
        //   type: "warning",
        //   closeOnClickModal: false,
        // })
        //   .then(() => {
            let this_ = this;
            let callback = res => {
              if (res.code == "0000") {
                this_.getGiftItemList();
              }
            };
            let param = {
              id: id,
              deleteFlag: 1
            };
            marketRequest.promotionGiftItemDeleteById(param, callback);
          // })
          // .catch(() => {});
      },
      changeInput(e) {
        this.$forceUpdate();
      },
      updateGiftItem(row) {
        if (row.itemId == null || typeof row.itemId == "undefined") {
          return;
        }
        if(!this.checkGiftProductLimits(row)){
          return;
        }
        let callback = res => {
          if (res.code == "0000") {
          }
        };
        let param = {
          id: row.itemId,
          giftNum: row.giftNum,
          channelMerchantLimit: row.channelMerchantLimit,
          channelIndividualLimit: row.channelIndividualLimit,
          individualLimit: row.individualLimit,
          upgradeAmount: row.upgradeAmount,
          channelStoreLimit: row.channelStoreLimit
        };
        marketRequest.promotionGiftItemUpdate(param, callback);
      },
      resetMerchantProductSearch() {
         //需要校验的keys
        let keys = ["categoryName","mpName","mpCode","storeId"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.merchantProductSearchForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("merchantProductSearchForm");
        this.merchantProductSearch();
      },
      // 模板下载
      downloadTemplate() {
        window.location.href =
          this.utils.getHost() + "jic-market/resource/download?key=FULL";
      },
      // 批量删除
      batchDelProduct() {
        let ids = [];
        this.allProductData.forEach(function(item,index,array){
          //判断父下面是否全选
          if(item.typeOfProduct == '10' && item.isCheck){
            if(item.children && item.children.length > 0){
              let isCheckItems = item.children.filter(function (subItem, index) {
                return !subItem.isCheck;
              });
              if(!(isCheckItems && isCheckItems.length > 0)){
                ids.push(item.id);
              }
            }else{
              ids.push(item.id);
            }
          }else if(item.typeOfProduct == '20' && item.isCheck){
            ids.push(item.id);
          }
        });
        if (ids.length == 0) {
          this.$message({ message: "未选择删除条目", type: "error" });
          return;
        }

        this.$confirm('确认批量删除已选内容？', "提示", {
          type: "warning",
          closeOnClickModal: false,
        }).then(() => {
          let this_ = this;
          let callback = function(res) {
            if (res.code == "0000") {
              // 成功查询本地促销商品
              this_.getProductListV2(0, null);
            } else {
              this.$message({ message: "删除商品失败", type: "fail" });
            }
          };
          let param = {};
          param.ids = ids;
          marketRequest.promotionMerchantProductDeleteBatch(param, callback);
        }).catch(() => {});

      },
      resetStoreSearch() {
         //需要校验的keys
        let keys = ["storename","storecode"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.storeSearchForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("storeSearchForm");
        this.mainStoreTableDataFormFind();
      },
      storeSearch() {
        this.mainStoreTableDataFormFind();
      },

      resetMerchantSearch() {
         //需要校验的keys
        let keys = ["orgNumber","merchantName"]
        //调用校验
        let  boo = this.seachTableUtils.checkFromIsNull(this.merchantSearchForm,keys)
        if(!boo){
          return;
        }
        this.resetForm("merchantSearchForm");
        this.mainMerchantFormFind();
      },
      merchantSearch() {
        this.mainMerchantFormFind();
      },
      genDescriptionPlaceholder() {
        let placeholder = "";
        if (
          typeof this.filters.frontPromType == "undefined" ||
          this.filters.frontPromType == null
        ) {
          return "";
        }
        if (this.filters.frontPromType == 15) {
          placeholder = "满x元换购商品";
        } else if (this.filters.frontPromType == 16) {
          placeholder = "满x件换购商品";
        }
        return placeholder;
      },
      saveTemplate() {
        let this_ = this;
        this.$refs["templateDataForm"].validate(valid => {
          if (valid) {
            let callback = res => {
              if (res.code == "0000") {
                this_.templateDialogVisible = false;
              } else {
                this_.$message({ message: "模板名称重复", type: "error" });
              }
            };
            this_.templateDataForm.id = this_.filters.id;
            marketRequest.promotionSaveTemplate(this_.templateDataForm, callback);
          }
        });
      },
      handleCurrentChangeMerchantProductTableData(pageNum) {
        this.merchantProductSearchForm.start = pageNum;
        this.getProductListV2(0, null);
      },
      handleSizeChangeMerchantProductTableData(val) {
        this.merchantProductSearchForm.limit = val;
        this.getProductListV2(0, null);
      },
      /**
       * 渠道选择
       */
      channelCheckChange(data, checked, indeterminate) {
        let index = this.dataForm.channelIds.indexOf(data.id);
        if (index != -1) {
          //存在
          this.dataForm.channelIds.splice(index, 1);
        } else {
          //不存在
          this.dataForm.channelIds.push(data.id);
        }
      },
      /**
       * 标签分类查询
       */
      getTagCategoryList() {
        let that = this;
        this.utils.request.getTagCategoryList({}, res => {
          that.tagCategoryList = res.data.rows;
        });
      },
      /**
       * 新增标签
       */
      addNewTag() {
        this.$refs["addTagForm"].validate(valid => {
          if (valid) {
            //TODO 新增标签
            // this.addTagForm
            let that = this;
            this.utils.request.addTag(this.addTagForm, res => {
              if (res.code == "0000") {
                that.getTagList();
                that.addTagDialogFormVisible = false;
                that.filters.labelId = res.data;
              }
            });
          } else {
            return false;
          }
        });
      },
      /**
       * 新增标签弹窗
       */
      addtags() {
        if (this.$refs["addTagForm"] != undefined) {
          this.$refs["addTagForm"].resetFields();
        }
        this.addTagDialogFormVisible = true;
      },
      // SeckillTimeChanage(e){
      //   let startTime = formatDate(e[0],"yyyy-MM-dd hh:mm:ss");
      //   let startTimeArray = startTime.split(" ");
      //   if(startTimeArray[1] == '00:00:00'){
      //     //
      //     startTime = startTimeArray[0] + " "+ formatDate(new Date(),"yyyy-MM-dd hh:mm:ss").split(" ")[1];
      //   }
      //   let endTime = formatDate(e[1],"yyyy-MM-dd hh:mm:ss");
      //   let endTimeArray = endTime.split(" ");
      //   if(endTimeArray[1] == '00:00:00'){
      //     //
      //     endTime = endTimeArray[0] + " "+ formatDate(new Date(),"yyyy-MM-dd hh:mm:ss").split(" ")[1];
      //   }
      //   //
      //   this.dataForm.startTime = startTime
      //   this.dataForm.endTime = endTime
      //   let startYearDate = startTime.split("-");
      //   let startTimeDate = startTime.split(":");
      //
      //   let endYearDate = endTime.split("-");
      //   let endTimeDate = endTime.split(":");
      //   //
      //   this.dataForm.SeckillTime = [
      //     new Date(startYearDate[0],startYearDate[1],startYearDate[2].split(" ")[0],startTimeDate[0].split(" ")[1],startTimeDate[1],startTimeDate[2]),
      //     new Date(endYearDate[0],endYearDate[1],endYearDate[2].split(" ")[0],endTimeDate[0].split(" ")[1],endTimeDate[1],endTimeDate[2])
      //   ]
      //   //
      // },
      merchantProductSearch() {
        this.getProductListV2(0, this.merchantProductSearchForm);
      },
      //添加赠品
      addCoupons(index, row) {
        this.currentRule = row;
        this.giftCouponsVisible = true;
        this.giftCouponsAddFlag = true;
      },
      /*
        备注无法编辑
       */
      changeRemark(val) {
        this.$forceUpdate();
      },
      checkCoupons(row) {
        this.giftCouponsAddFlag = false;
        this.currentRule = row;
        this.giftCouponsVisible = true;
        let this_ = this;
        //查询promotion_gift_item 列表并赋值给
        let callback = function(res) {
          if (res.code == "0000") {
            this_.giftCouponsTableData = res.data.map((ele, index) => {
              let item = {
                id: 1,
                couponId: 100000 + index,
                couponName: "优惠券0" + index,
                couponAmount: 50,
                couponUseStartTime: "2020-03-03 15:36:29",
                couponUseEndTime: "2020-05-03 15:36:29",
                grantTotalNum: 10000 + index,
                useTotalAmountLimit: 2001 + index
              };
              return item;
            });
          }
        };
        let params = {
          promotionId: this.promotionId,
          promotionRuleId: this.currentRule.id,
          giftType: 4
        };
        marketRequest.promotionGiftItemFindAll(params, callback);
      },
      //优惠券列表查询,目前优惠券接口有问题，mock假数据
      giftCouponsFormFind() {
        let this_ = this;
        let callback = res => {
          if (res.code == "0000") {
            this_.giftCouponsTableData = res.data.rows.map((ele, index) => {
              let item = {
                id: 1,
                couponId: 100000 + index,
                couponName: "优惠券0" + index,
                couponAmount: 50,
                couponUseStartTime: "2020-03-03 15:36:29",
                couponUseEndTime: "2020-05-03 15:36:29",
                grantTotalNum: 10000 + index,
                useTotalAmountLimit: 2001 + index
              };
              return item;
            });
            this_.giftCouponsTableDataSize = parseInt(res.data.total);
          }
        };
        this.utils.request.couponQueryConfig(this.giftCouponsForm, callback);
      },
      //校验分摊比例是否相加等于11
      checkAllocationRatio() {
        let allRatio =
          this.filters.parentAllocationScale +
          this.filters.childAllocationScale +
          this.filters.merchantAllocationScale +
          this.filters.storeAllocationScale;
        if (allRatio) {
        }
      },
      //获取活动列表
      getTagList() {
        let this_ = this;
        this.tagList = [
          { id: 1, tagName: "标签1" },
          { id: 2, tagName: "标签2" },
          { id: 3, tagName: "标签3" }
        ];
        let callback = res => {
          if (res.code == "0000") {
            this_.tagList = res.data.rows;
          }
        };
        this.utils.request.getTagList({ start: 1, limit: 1000 }, callback);
      },
      addPromotionRuleSet() {
        this.filters.promotionRules.push({
          level: this.filters.promotionRules.length + 1
        });
      },
      removePromotionRuleSet(index, val) {
        this.filters.promotionRules.splice(index, 1);
        if (this.promotionId != null && val.id != "undefined") {
          let callback = function(res) {
            if (res.code == "0000") {
            } else {
              //alert("修改失败");
            }
          };
          let param = {
            id: val.id,
            promotionId: this.promotionId
          };
          this.utils.request.promotionRuleDelete(param, callback);
        }
      },
      // setep3--start
      seeMoreDeatil(row) {
        this.$router.push(`/QueryPromotion?value=${row.promotionId}&auth=0`);
      },
      handleClickMerchantProduct(tab, event) {
        if (tab.label == "生效商品") {
          this.getProductListV2(0, null);
        } else {
          this.getProductListV2(1, null);
        }
      },
      //互斥查看更多
      seeMore(row) {
        this.mutexDetailDialogVisible = true;
        this.mutexPromotionTable = [
          {
            promotionId: 26,
            promName: "测试互斥活动1",
            mutexTime: "2019-09-26 14:28:31 - 2019-10-04 14:28:34",
            mutexChannel: "BBC",
            mutexStroeName: "张小二bbc店铺"
          },
          {
            promotionId: 27,
            promName: "测试互斥活动2",
            mutexTime: "2020-01-26 14:28:31 - 2020-02-28 19:45:11",
            mutexChannel: "BBC",
            mutexStroeName: "张小二店铺"
          }
        ];
        //TODO 调用接口获取互斥活动列表
      },
      batchSaveV2() {
        let this_ = this;
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
        this.productPromotionListObject.productPromotionList.splice(
          0,
          this.productPromotionListObject.productPromotionList.length
        );
        for (let i = 0; i < this.productAddSelection.length; i++) {
          let temp = {};
          temp.promotionId = this.promotionId;
          temp.mpId = this.productAddSelection[i].id;
          temp.spuId = this.productAddSelection[i].id;
          this.productPromotionListObject.productPromotionList.push(temp);
        }
        let callback = res => {
          if (res.code == "0000") {
            // 查询本地促销商品
            this_.getProductListV2(0, null);
            this_.getMutexProductList();
          }
        };
        marketRequest.saveBatchV3(this.productPromotionListObject, callback);

        // let this_ = this;
        // this.dialogVisibleTwo = !this.dialogVisibleTwo;
        // this.productPromotionListObject.productPromotionList.splice(0,this.productPromotionListObject.productPromotionList.length);
        // for (let i = 0; i < this.productAddSelection.length; i++) {
        //   let temp = {};
        //   temp.promotionId = this.promotionId;
        //   temp.mpId = this.productAddSelection[i].id;
        //   this.productPromotionListObject.productPromotionList.push(temp);
        // }
        // let callback = res => {
        //   if (res.code == "0000") {
        //     // 查询本地促销商品
        //     this_.getProductListV2(0, null);
        //   }
        // };
        // marketRequest.saveBatchV2(this.productPromotionListObject, callback );
      },

      reloadMutexV2(row) {
        let this_ = this;
        let param = {
          mpId: row.mpId,
          promotionMerchantProductId: row.id,
          promotionId: this.promotionId
        };
        let callback = res => {
          if (res.code == "0000") {
            // 查询本地促销商品
            this_.getProductListV2(1, null);
          }
        };
        marketRequest.reloadMutexV2(param, callback);
      },

      getProductListV2(type, searchParm) {
        let this_ = this;
        let callback = function(res) {
          if (res.code == "0000") {
            this_.isAllProductChecked = false;
            this_.isIndeterminateProductCheck = false;
            if (type == 0 && res.data.total > 0) {
              this_.merchantProductTableData = res.data.rows;
              this_.merchantProductTableDataTotal = res.data.total;
              this_.merchantProductTotalCount = res.data.totalCount;
              this_.allProductData = getAllRow(this_.merchantProductTableData, []);
            } else {
              this_.merchantProductTableData = [];
              this_.merchantProductTableDataTotal = 0;
              this_.merchantProductTotalCount = 0;
            }
          } else {
          }
        };
        this.merchantProductSearchForm.promotionId = this.promotionId;
        marketRequest.getProductListV3(this.merchantProductSearchForm, callback);

        // let this_ = this;
        // let callback = function(res) {
        //   //
        //   if (res.code == "0000") {
        //     if(type == 0 && res.data.total > 0){
        //       this_.merchantProductTableData = res.data.rows;
        //       this_.merchantProductTableDataTotal = res.data.total;
        //     }else{
        //       this_.merchantProductTableDataMutex = res.data.rows;
        //     }
        //   } else {
        //   }
        // };
        // this.merchantProductSearchForm.promotionId = this.promotionId;
        // marketRequest.getProductListV2(this.merchantProductSearchForm, callback);
      },
      getGiftItemList() {
        let this_ = this;
        //查询promotion_gift_item 列表并赋值给
        let callback = function(res) {
          if (res.code == "0000") {
            this_.giftProductTableData = res.data.rows.map((ele, index) => {
              let item = {};
              item.id = ele.mmpId;
              item.code = ele.mpCode;
              item.chineseName = ele.mpName;
              item.storeName = ele.storeName;
              item.merchantName = ele.merchantName;
              item.upgradeAmount = ele.upgradeAmount;
              item.channelMerchantLimit = ele.channelMerchantLimit;
              item.channelStoreLimit = ele.channelStoreLimit;
              item.individualLimit = ele.individualLimit;
              item.itemId = ele.id;
              item.stock = ele.stock;
              item.goodsCategory = ele.goodsCategory;
              item.salePrice = ele.salePrice;
              item.measureUnit = ele.measureUnit;
              return item;
            });
            this_.seeGiftProductTableDataSize = res.data.total;
          }
        };
        //let params = {"promotionId": this.promotionId, "promotionRuleId": this.currentRule.id,"giftType":1};
        this.seeGiftProductForm.promotionId = this.promotionId;
        this.seeGiftProductForm.promotionRuleId = this.currentRule.id;
        this.seeGiftProductForm.giftType = 1;
        marketRequest.promotionGiftItemFindByPage(
          this.seeGiftProductForm,
          callback
        );
      },

      checkPro(row) {
        this.giftAddFlag = false;
        if (row != null) {
          this.currentRule = row;
        }
        //查看换购商品时清空数组
        this.giftProductTableData = [];
        this.giftProductVisible = true;
        this.getGiftItemList();
      },

      updatePromotionRule(item) {
        let this_ = this;
        let callback = function(res) {
          if (res.code == "0000") {
          }
        };
        let param = {
          id: item.id,
          conditionValue: item.conditionValue
        };
        this.utils.request.promotionRuleUpdate(param, callback);
      },
      // setep3--start
      addGiftRule() {
        let this_ = this;
        //this.giftRuleTable.push({});
        let callback = function(res) {
          if (res.code == "0000") {
            this_.giftRuleTable = res.data;
          }
        };
        let param = {
          promotionId: this.filters.id,
          conditionType: this.filters.frontPromType == 15 ? 1 : 2,
          conditionValue: null,
          contentType: this.filters.frontPromType
        };
        this.utils.request.promotionRuleSave(param, callback);
        //新增数据&&回显
      },
      deleteGiftRule(item) {
        let this_ = this;
        let callback = function(res) {
          if (res.code == "0000") {
            this_.giftRuleTable = res.data;
          }
        };
        let param = {
          id: item.id,
          promotionId: this.filters.id
        };
        this.utils.request.promotionRuleDelete(param, callback);
      },
      handleProductClick(tab, event) {
        if (tab.label.indexOf("换购商品") > -1) {
          let this_ = this;
          let callback = function(res) {
            if (res.code == "0000") {
              this_.giftRuleTable = res.data;
            }
          };
          let param = {
            promotionId: this.filters.id,
            deleteFlag: 0
          };
          this.utils.request.promotionRuleFindAll(param, callback);
        }
      },
      //更新价格或者限量-todo
      updatePriceOrLimit(val) {
        let jsonVal = JSON.stringify(val);
        let callback = function(res) {
          if (res.code == "0000") {
            val.limitRuleId = res.data;
          } else {
            //alert("修改失败");
          }
        };
        let temp = {};
        temp.id = val.limitRuleId == 0 ? null : val.limitRuleId;
        temp.promotionId = val.promotionId;
        temp.promotionId = val.promotionId;
        temp.mpId = val.mpId;
        temp.channelStoreLimit = val.channelStoreLimit;
        temp.channelIndividualLimit = val.channelIndividualLimit;
        temp.promPrice = val.promPrice;
        temp.individualLimit = val.individualLimit;
        temp.channelMerchantLimit = val.channelMerchantLimit;
        temp.limitType = val.typeOfProduct;
        marketRequest.promotionLimitRuleInsert(temp, callback);
      },
      //批量添加商品
      productSaveBatch() {
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
        this.productPromotionListObject.productPromotionList.splice(
          0,
          this.productPromotionListObject.productPromotionList.length
        );

        for (let i = 0; i < this.productAddSelection.length; i++) {
          let temp = {};
          temp.promotionId = this.promotionId;
          temp.mpId = this.productAddSelection[i].id;
          temp.mpName = this.productAddSelection[i].chineseName; // 商品名称
          temp.merchantName = this.productAddSelection[i].name; //商家名称
          temp.storeName = this.productAddSelection[i].storeName; //店铺名称
          //temp.salePriceWithTax = this.productAddSelection[i].salePriceWithTax;  //零售价
          temp.mpCode = this.productAddSelection[i].code; //商品编码
          temp.mpParentId = this.productAddSelection[i].parentId;
          temp.merchantId = this.productAddSelection[i].merchantId;
          temp.categoryId = this.productAddSelection[i].categoryId;
          // temp.categoryName     = this.productAddSelection[i].categoryName;    类别名称
          temp.picUrl = this.productAddSelection[i].pictureUrl;
          this.productPromotionListObject.productPromotionList.push(temp);
        }

        let callback = res => {
          if (res.code == "0000") {
            // 查询本地促销商品
            this.mainProductTableDataFormFind();
          }
        };

        this.utils.request.promotionMerchantProductSaveBatch(
          this.productPromotionListObject,
          callback
        );
      },
      productTableDataSubmit2() {
        this.batchSaveV2();
      },
      //确定 选择商品
      productTableData2Click() {
        // 调添加商品 接口
        this.productTableDataSubmit2();
      },
      //确定 选择赠品
      giftProductTableData2Click() {
        //添加换购商品则判断选中的否则判断已保存的
        if(this.giftAddFlag){
          for (let i = 0; i < this.giftProductAddSelection.length; i++) {
            if(!this.checkGiftProductLimits(this.giftProductAddSelection[i])){
              return;
            }
          }
        }else{
          for (let i = 0; i < this.giftProductTableData.length; i++) {
            if(!this.checkGiftProductLimits(this.giftProductTableData[i])){
              return;
            }
          }
        }

        let callback = res => {
          if (res.code == "0000") {
            this.giftProductVisible =false;
          }
        };

        let items = this.giftProductAddSelection.map((ele, index) => {
          let item = {};
          item.promotionId = this.promotionId;
          item.giftRef = ele.id;
          item.mmpId = ele.id;
          item.storeId = ele.storeId;
          item.storeName = ele.storeName;
          item.channelCode = ele.dataType == 2 ? -1 : ele.channelCode;
          item.mpCode = ele.code;
          item.mpName = ele.chineseName;
          item.giftType = 1;
          item.giftLevel = null;
          item.promotionRuleId = this.currentRule.id;
          //item.giftNum = ele.giftNum;
          item.upgradeAmount = ele.upgradeAmount;
          item.channelMerchantLimit = ele.channelMerchantLimit;
          item.channelStoreLimit = ele.channelStoreLimit;
          item.individualLimit = ele.individualLimit;
          item.companyId = ele.companyId;
          item.merchantId = ele.merchantId;
          item.productId = ele.productId;
          return item;
        });
        marketRequest.promotionGiftItemSaveBatch({ list: items }, callback);
      },
      giftCouponsTableData2Click() {
        let callback = res => {
          if (res.code == "0000") {
          }
        };
        let items = this.giftCouponsAddSelection.map((ele, index) => {
          let item = {};
          item.promotionId = this.promotionId;
          item.giftRef = ele.id;
          item.mmpId = ele.dataType == 2 ? ele.id : null;
          item.storeId = ele.storeId == 0 ? null : ele.storeId;
          item.storeName = ele.storeName;
          item.channelCode = ele.dataType == 2 ? -1 : ele.channelCode;
          item.giftType = 4;
          item.giftLevel = null;
          item.promotionRuleId = this.currentRule.id;
          item.giftNum = ele.giftNum;
          item.channelIndividualLimit = ele.channelIndividualLimit;
          item.merchantId = ele.merchantId;
          item.giftNode = this.giftNode;
          return item;
        });
        marketRequest.promotionGiftItemSaveBatch({ list: items }, callback);
      },
      // 选择商品
      addSelectionChangeProduct(val) {
        let this_ = this;
        this_.productAddSelection = val;
      },
      addSelectionChangeGiftCoupons(val) {
        let this_ = this;
        this_.giftCouponsAddSelection = val;
      },
      // 选择商品
      addSelectionChangeGiftProduct(val) {
        let this_ = this;
        this_.giftProductAddSelection = val;
      },
      //修改table header的背景色
      tableHeaderColor({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return "background-color:rgb(250,250,250);";
        }
      },
      //table的双色条纹
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex === 1) {
          return "warning-row";
        } else if (rowIndex === 3) {
          return "success-row";
        }
        return "";
      },
      add() {
        this.dialogVisibleTwo = true;
        this.tableDataTwo = [];
        this.productFormFind();
      },
      producthandleSizeChange(pageSize) {
        this.productForm.start = 1;
        this.productForm.limit = pageSize;
        this.productFormFind();
      },
      producthandleCurrentChange(pageNum) {
        this.productForm.start = pageNum;
        this.productFormFind();
      },
      // 商品方法开始
      productFormFind() {
        let that_ = this;
        this.productForm.storeIds = this.storeTableData.map((ele, index) => {
          return ele.storeId;
        });
        this.productForm.promotionId = this.filters.id;
        marketRequest.promotionSpuPageByPromotionId(this.productForm, function(
          resp
        ) {
          if (resp.code == "0000") {
            if(resp.data.rows == null || resp.data.rows.length < 1){
              that_.tableDataTwo = [];
              that_.productListTotal = 0;
            }else{
              that_.tableDataTwo = resp.data.rows.map((ele, index) => {
              let spu = {};
              spu.id = ele.id;
              spu.code = ele.code;
              spu.chineseName = ele.chineseName;
              spu.totalStock = ele.totalStock;
              spu.goodsCategory = ele.fullNamePath;
              spu.merchantName = ele.merchantName;
              spu.storeName = ele.storeName;
              spu.salePriceScope = ele.salePriceWithTax;
              // spu.measureUnit = ele.measureUnit;
              return spu;
            });
            that_.productListTotal = Number(resp.data.total);
            }
          }
        });

        // let that_ =this;
        // that_.utils.request.queryshopApi(this.productForm, function (resp) {
        //   if (resp.code == "0000") {
        //     that_.tableDataTwo= resp.data.rows;
        //     that_.productListTotal= resp.data.total;
        //   }
        //
        //   that_.tableDataTwo= resp.data.rows;
        // });
      },
      // 商品方法开始
      giftProductFormFind() {
        let that_ = this;
        this.giftProductForm.promotionId = this.filters.id;
        this.giftProductForm.storeIds = this.storeTableData.map((ele, index) => {
          return ele.storeId;
        });
        marketRequest.promotionSkuPageByPromotionId(
          this.giftProductForm,
          function(resp) {
            if (resp.code == "0000") {
              that_.giftProductTableData = resp.data.rows.map((ele, index) => {
                let sku = {};
                sku.id = ele.id;
                sku.code = ele.code;
                sku.chineseName = ele.chineseName;
                sku.totalStock = ele.totalStock;
                sku.goodsCategory = ele.fullNamePath;
                sku.merchantName = ele.merchantName;
                sku.storeName = ele.storeName;
                sku.salePriceScope = ele.salePriceWithTax;
                // sku.id = ele.id;
                // sku.code = ele.thirdSkuId;
                // sku.chineseName = ele.goodsName;
                // sku.unitsName = ele.measureUnit;
                // sku.merchantName = ele.merchantName;
                // sku.storeName = ele.storeName;
                sku.storeId = ele.storeId;
                sku.merchantId = ele.merchantId;
                sku.giftNum = 1;
                sku.salePrice = ele.salePrice;
                return sku;
              });
              that_.giftProductTableDataSize = resp.data.total;
            }
          }
        );
        // let that_ =this;
        // that_.utils.request.queryshopApi(this.giftProductForm, function (resp) {
        //   if (resp.code == "0000") {
        //     that_.giftProductTableData= resp.data.rows;
        //     that_.giftProductTableDataSize = resp.data.total;
        //   }
        // });
      },

      //添加赠品
      addPro(index, row) {
        this.currentRule = row;
        this.giftProductVisible = true;
        this.giftAddFlag = true;
        this.giftProductTableData = [];
        this.giftProductFormFind();
      },
      resetForm(formName) {
        if (this.$refs[formName] != undefined) {
          this.$refs[formName].resetFields();
        }
      },
      // setep3--end

      shenheHuodong(flag) {
        let _this = this;
        if (flag == 0) {
          this.$confirm("确认提交审核？", "提示", {
            type: "warning"
          })
            .then(() => {
              let callback = res => {
                if (res.code == "0000") {
                  _this.filters.status = 2;
                }
              };
              let param = {};
              param.id = this.promotionId;
              param.status = 2;
              this.utils.request.promotionUpdate(param, callback);
            })
            .catch(() => {});
        } else {
          this.dialogVisibleAdmin = true;
        }
      },
      detailList() {
        this.$router.push({
          path: `/pages/promotionManagement/increasePromotion`
        });
      },
      submitFormAdminNotPass() {
        this.$refs.adminDataForm.validate(auditRemarkE => {
          if (auditRemarkE) {
            let _this = this;
            let callback = res => {
              if (res.code == "0000") {
                _this.dialogVisibleAdmin = false;
                _this.filters.status = 4;
                _this.auditCount = 1;
              }
            };
            this.adminDataForm.id = this.promotionId;
            this.adminDataForm.status = 4;
            this.utils.request.promotionUpdate(this.adminDataForm, callback);
          }
        });
      },
      submitFormAdmin() {
        let _this = this;
        let callback = res => {
          if (res.code == "0000") {
            _this.dialogVisibleAdmin = false;
            _this.filters.status = 11;
          }
        };
        this.adminDataForm.id = this.promotionId;
        this.adminDataForm.status = 11;
        this.utils.request.promotionUpdate(this.adminDataForm, callback);
      },

      resetForm(formName) {
        if (this.$refs[formName] != undefined) {
          this.$refs[formName].resetFields();
        }
      },
      //---------------------------店铺------------------------------------------------start
      //查询店铺
      storeFormFind() {
        //商家 取出商家id-->merchantId
        let ids = this.merchantTableData2.map(item => item.merchantId).toString();
        // let params = [];
        // let idArray = (ids + "").split(",");
        // for (var i = 0; i < idArray.length; i++) {
        //   params.push({id: idArray[i]});
        // }
        if (this.merchantTableData2.length == 0) {
          this.$message({ message: "请先选择商家", type: "success" });
        }
        //this.storeTableData2.splice(0, this.storeTableData2.length);
        var this__ = this;
        this.storeForm.merchantIds = ids;
        this.utils.request.queryByIds(this.storeForm, function(res) {
          if (res.code == "0000") {
            this__.storeTableData2 = res.data.rows;
            this__.merchantTableDataTatolStore = res.data.total;
          }
        });
      },
      storeTableDataselectionChange(val) {
        this.storeTableDataSelection = val;
      },
      merchantTableData2selectionChange(val) {
        this.merchantTableData2Selection = val;
      },
      //选择店铺
      storeTableData2AddSelectionChange(val) {
        this.addSelectionStoreTableData2 = val;
      },
      //确定 选择店铺
      storeTableData2Click() {
        // 调添加店铺 关系接口
        this.merchantTableDataSubmit2();
      },
      merchantTableDataSubmit2() {
        // let callback = res => {
        //   //
        //   if (res.code == "0000") {
        //     this.storeSaveBatch();
        //   }
        // };
        //调接口
        //删除这个活动老的数据
        //批量添加新的数据
        // this.promotion.id=null;
        // this.promotion.promotionId=this.promotionId;
        // this.promotion.merchantType="2";
        this.storeSaveBatch();
        //this.utils.request.promotionMerchantDeleteByPromotionId(this.promotion, callback);
      },

      //批量添加店铺
      storeSaveBatch() {
        let flag = true;
        // this.storeTableData.forEach(res => {
        //   this.addSelectionStoreTableData2.forEach(item => {
        //     if (res.storeId == item.id) {
        //       this.$message({ message: "不能添加重复店铺", type: "error" });
        //       flag = false;
        //     }
        //   });
        // });
        if (!flag) {
          return;
        }

        this.pomotionListObject.pomotionList.splice(
          0,
          this.pomotionListObject.pomotionList.length
        );

        for (var i = 0; i < this.addSelectionStoreTableData2.length; i++) {
          var temp = {};

          temp.promotionId = this.promotionId;
          temp.storeId = this.addSelectionStoreTableData2[i].id;
          temp.merchantType = "2";
          temp.storeName = this.addSelectionStoreTableData2[i].storeName;
          temp.storeCode = this.addSelectionStoreTableData2[i].storeCode;
          temp.storeType = this.addSelectionStoreTableData2[i].storeType;
          temp.merchantId = this.addSelectionStoreTableData2[i].merchantId;
          temp.merchantName = this.addSelectionStoreTableData2[i].merchantName;
          temp.orgNumber = this.addSelectionStoreTableData2[i].orgNumber;
          this.pomotionListObject.pomotionList.push(temp);
        }
        let callback = res => {
          if (res.code == "0000") {
            this.mainStoreTableDataFormFind();
          }
        };

        this.utils.request.promotionMerchantSaveBatch(
          this.pomotionListObject,
          callback
        );
      },
      //查询绑定关系的店铺
      mainStoreTableDataFormFind() {
        // this.storeTableData
        this.storeSearchForm.merchantType = "2";
        this.storeSearchForm.promotionId = this.promotionId;
        var this__ = this;
        this.utils.request.promotionMerchantList(this.storeSearchForm, function(
          res
        ) {
          if (res.code == "0000") {
            var ret = [];
            for (var i = 0; i < res.data.list.length; i++) {
              var temp = {};
              temp.promotionId = res.data.list[i].promotionId;
              temp.id = res.data.list[i].id;
              temp.storeId = res.data.list[i].storeId;
              temp.storeName = res.data.list[i].storename;
              temp.storeCode = res.data.list[i].storecode;
              temp.storeType = res.data.list[i].storeType;

              ret.push(temp);
            }
            //店铺调试
            this__.storeTableData = res.data.list;
            this__.storeTableDataTatol = res.data.totalCount;
          }
        });
      },

      // 换页刷新
      mainSroreMerchantRefreshPageRequest: function(pageNum) {
        this.storeSearchForm.pageNo = pageNum;
        this.mainStoreTableDataFormFind();
      },
      // 换页刷新
      mainSroreMerchantHandleSizeChange: function(pageSize) {
        this.storeSearchForm.pageNo = 1;
        this.storeSearchForm.pageSize = pageSize;
        this.mainStoreTableDataFormFind();
      },

      // 换页刷新
      refreshPageRequestStore: function(pageNum) {
        this.merchantFormStore.start = pageNum;
        // this.merchantFormFind();
        this.storeFormFind();
      },
      // 换页刷新
      handleSizeChangeStore: function(pageSize) {
        this.merchantForm;
        this.merchantFormStore.limit = pageSize;
        this.merchantFormStore.start = 1;
        this.storeFormFind();
      },

      //---------------------------店铺------------------------------------------------end

      //---------------------------商家------------------------------------------------start

      //---------------------------分页------------------------------------------------start
      // 换页刷新
      refreshPageRequest: function(pageNum) {
        this.merchantForm.start = pageNum;
        this.merchantFormFind();
      },
      // 换页刷新
      handleSizeChange: function(pageSize) {
        this.merchantForm.limit = pageSize;
        this.merchantForm.start = 1;
        this.merchantFormFind();
      },

      // 换页刷新
      mainMerchantRefreshPageRequest: function(pageNum) {
        this.merchantSearchForm.pageNo = pageNum;
        this.mainMerchantFormFind();
      },
      // 换页刷新
      mainMerchantHandleSizeChange: function(pageSize) {
        this.merchantSearchForm.pageNo = 1;
        this.merchantSearchForm.pageSize = pageSize;
        this.mainMerchantFormFind();
      },
      //查询绑定关系的商家
      mainMerchantFormFind() {
        this.merchantSearchForm.merchantType = "1";
        var this__ = this;
        this.merchantSearchForm.promotionId = this.promotionId;
        this.utils.request.promotionMerchantList(
          this.merchantSearchForm,
          function(res) {
            if (res.code == "0000") {
              var ret = [];
              for (var i = 0; i < res.data.list.length; i++) {
                var temp = {};
                temp.id = res.data.list[i].id;
                temp.name = res.data.list[i].merchantName;
                temp.orgNumber = res.data.list[i].orgNumber;
                temp.merchantType = res.data.list[i].merchantTypeManager;
                temp.merchantId = res.data.list[i].merchantId;

                ret.push(temp);
              }

              this__.merchantTableData2 = ret;
              this__.mainMerchantTableDataTatol = res.data.totalCount;
            }
          }
        );
      },
      // 删除店铺
      storeDelete(id) {
        // this.$confirm("是否确认删除？", "提示", {
        //   type: "warning",
        //   closeOnClickModal: false,
        // })
        //   .then(() => {
            let callback = res => {
              this.mainStoreTableDataFormFind();
              if (res.code == "0000" && res.data == "1") {
                //删除成功再调分页
                this.$message({ message: "删除成功", type: "success" });
              } else {
                this.$message({ message: "操作失败, " + res.msg, type: "error" });
              }
            };
            this.promotion.id = id;
            this.utils.request.promotionMerchantDeleteById(
              this.promotion,
              callback
            );
          // })
          // .catch(() => {});
      },

      //---------------------------分页------------------------------------------------end
      //删除商家
      merchantTableData2delete(id) {
        // this.$confirm("是否确认删除？", "提示", {
        //   type: "warning",
        //   closeOnClickModal: false,
        // })
        //   .then(() => {
            let callback = res => {
              this.mainMerchantFormFind();
              this.mainStoreTableDataFormFind();
              if (res.code == "0000" && res.data == "1") {
                //删除成功再调分页
                this.$message({ message: "删除成功", type: "success" });
              } else {
                this.$message({ message: "操作失败, " + res.msg, type: "error" });
              }
            };
            this.promotion.id = id;
            this.utils.request.promotionMerchantDeleteById(
              this.promotion,
              callback
            );
          // })
          // .catch(() => {});
      },
      //选择商家
      addSelectionChange(val) {
        this.addSelection = val;
      },
      //提交 选择商家
      merchantTableDataSubmit() {
        let callback = res => {
          if (res.code == "0000") {
            this.promotionMerchantSaveBatch();
          }
        };
        //调接口
        //删除这个活动老的数据
        //批量添加新的数据
        this.promotion.id = null;
        this.promotion.promotionId = this.promotionId;
        this.promotion.merchantType = "1";
        this.promotionMerchantSaveBatch();
        //this.utils.request.promotionMerchantDeleteByPromotionId(this.promotion, callback);
      },
      promotionMerchantSaveBatch() {
        let flag = true;
        // this.merchantTableData2.forEach(res => {
        //   this.addSelection.forEach(item => {
        //     //  ;
        //     if (res.merchantId == item.id) {
        //       this.$message({ message: "不能添加重复商家", type: "error" });
        //       flag = false;
        //     }
        //   });
        // });
        if (!flag) {
          return;
        }
        this.pomotionListObject.pomotionList.splice(
          0,
          this.pomotionListObject.pomotionList.length
        );

        for (var i = 0; i < this.addSelection.length; i++) {
          var temp = {};

          temp.promotionId = this.promotionId;
          temp.merchantId = this.addSelection[i].id;
          temp.merchantType = "1";
          temp.merchantName = this.addSelection[i].name;
          temp.merchantTypeManager = this.addSelection[i].merchantType;
          temp.orgNumber = this.addSelection[i].orgNumber;
          temp.name = this.addSelection[i].name;

          this.pomotionListObject.pomotionList.push(temp);
        }

        let callback = res => {
          if (res.code == "0000") {
            this.mainMerchantForm.merchantType = "1";
            this.mainMerchantFormFind();
          }
        };

        var this__ = this;
        this.utils.request.promotionMerchantSaveBatch(
          this.pomotionListObject,
          callback
        );

      },
      //查询商家
      merchantFormFind() {
        var this__ = this;
        //只有运营平台有使用渠道
        if (this.deptType == 0 && this.filters.channelCodes) {
          this.merchantForm.childIds = this.filters.channelCodes.split(',').map(item => item);
        }
        this.utils.request.queryMerchantList(this.merchantForm, function(res) {
          // this.utils.request.queryMerchantListOther(null, function (res) {
          if (res.code == "0000") {
            this__.merchantTableData = res.data.rows;
            this__.merchantTableDataTatol = res.data.total;
          }
        });
      },
      //---------------------------商家------------------------------------------------end

      //活动渠道
      handleCheckAllChange(val) {
        this.filters.channelCodes = val
          ? chanelCodesRadio.map(function(value, index, array) {
            return value.code;
          })
          : [];
        this.isIndeterminate = false;
      },
      handleCheckedCitiesChange(value) {
        let checkedCount = value.length;
        this.checkAll = checkedCount === this.chanelCodesRadios.length;
        this.isIndeterminate =
          checkedCount > 0 && checkedCount < this.chanelCodesRadios.length;
      },
      //活动平台
      handleCheckAllChange1(val) {
        this.filters.proPlatform = val
          ? proPlatformRadio.map(function(value, index, array) {
            return value.code;
          })
          : [];
        this.isIndeterminate1 = false;
      },
      handleCheckedCitiesChange1(value) {
        let checkedCount = value.length;
        this.checkAll1 = checkedCount === this.proPlatformRadios.length;
        this.isIndeterminate1 =
          checkedCount > 0 && checkedCount < this.proPlatformRadios.length;
      },

      //新老用户
      handleCheckAllChange2(val) {
        this.filters.proUserType = val
          ? proUserTypeRadio.map(function(value, index, array) {
            return value.code;
          })
          : [];
        this.isIndeterminate2 = false;
      },
      handleCheckedCitiesChange2(value) {
        let checkedCount = value.length;
        this.checkAll2 = checkedCount === this.proUserTypeRadios.length;
        this.isIndeterminate2 =
          checkedCount > 0 && checkedCount < this.proUserTypeRadios.length;
      },
      //会员类型
      handleCheckAllChange3(val) {
        this.filters.proMemberType = val
          ? proMemberTypeRadio.map(function(value, index, array) {
            return value.code;
          })
          : [];
        this.isIndeterminate3 = false;
      },
      handleCheckedCitiesChange3(value) {
        let checkedCount = value.length;
        this.checkAll3 = checkedCount === this.proMemberTypeRadios.length;
        this.isIndeterminate3 =
          checkedCount > 0 && checkedCount < this.proMemberTypeRadios.length;
      },
      //会员等级
      handleCheckAllChange4(val) {
        this.filters.proMemberLevel = val
          ? proMemberLevelRadio.map(function(value, index, array) {
            return value.code;
          })
          : [];
        this.isIndeterminate4 = false;
      },
      handleCheckedCitiesChange4(value) {
        let checkedCount = value.length;
        this.checkAll4 = checkedCount === this.proMemberLevelRadios.length;
        this.isIndeterminate4 =
          checkedCount > 0 && checkedCount < this.proMemberLevelRadios.length;
      },
      //添加商家
      querySupplierListForAdd() {
        this.editDialogVisible = true;
        this.promotion.merchantType = 1;
        //this.merchantTableData=[];
        this.merchantFormFind();
      },
      //添加店铺
      querySupplierListForAdd2() {
        this.editDialogVisible2 = true;
        this.promotion.merchantType = 2;
        //this.storeTableData2=[];
        this.storeFormFind();
      },
      delAllSelectedSupplierstoreTableData() {
        if (this.storeTableDataSelection.length == 0) {
          this.$message({ message: "未选择删除条目", type: "error" });
          return;
        }
        this.$confirm('确认批量删除已选内容？', "提示", {
          type: "warning",
          closeOnClickModal: false,
        }).then(() => {
          let ids = this.storeTableDataSelection.map(item => item.id).toString();
          let idArray = (ids + "").split(",");
          this.delAllSelectedSupplierstoreTableDataQueryList(idArray);
        }).catch(() => {});

      },
      delAllSelectedSupplierstoreTableDataQueryList(idArray) {
        let that = this;
        this.promotion.merchantType = "2";
        this.promotion.id = idArray[this.storeTableDataSelectionIndex];
        this.utils.request.promotionMerchantDeleteById(
          this.promotion,
          function() {
            that.storeTableDataSelectionIndex++;
            if (that.storeTableDataSelectionIndex < idArray.length) {
              that.delAllSelectedSupplierstoreTableDataQueryList(idArray);
            } else {
              //执行成功
              that.storeTableDataSelectionIndex = 0;
              that.$message({ message: "删除成功", type: "success" });
              that.mainStoreTableDataFormFind();
            }
          }
        );
      },
      //批量删除商家
      delAllSelectedSuppliermerchantTableData2() {
        if (this.merchantTableData2Selection.length == 0) {
          this.$message({ message: "未选择删除条目", type: "error" });
          return;
        }
        this.$confirm('确认批量删除已选内容？', "提示", {
          type: "warning",
          closeOnClickModal: false,
        }).then(() => {
          let ids = this.merchantTableData2Selection
            .map(item => item.id)
            .toString();
          let idArray = (ids + "").split(",");
          this.delAllSelectedSupplierQueryList(idArray);
        }).catch(() => {});

      },
      delAllSelectedSupplierQueryList(idArray) {
        let that = this;
        this.promotion.merchantType = "1";
        this.promotion.id = idArray[this.merchantTableData2SelectionIndex];
        this.utils.request.promotionMerchantDeleteById(
          this.promotion,
          function() {
            that.merchantTableData2SelectionIndex++;
            if (that.merchantTableData2SelectionIndex < idArray.length) {
              that.delAllSelectedSupplierQueryList(idArray);
            } else {
              //执行成功
              that.merchantTableData2SelectionIndex = 0;
              that.$message({ message: "删除成功", type: "success" });
              that.mainMerchantFormFind();
              that.mainStoreTableDataFormFind();
            }
          }
        );
      },

      // ------------------------------------商品开始方法-------------------------------------start

      // 换条数刷新
      handleSizeChangeForProduct: function(pageSize) {
        this.productForm.limit = pageSize;
        this.productForm.start = 1;
        this.productFormFind();
      },
      // 换条数刷新
      handleSizeChangeForGiftProduct: function(pageSize) {
        this.giftProductForm.limit = pageSize;
        this.giftProductForm.start = 1;
        this.giftProductFormFind();
      },
      handleSizeChangeForSeeGiftProduct(pageSize) {
        this.seeGiftProductForm.limit = pageSize;
        this.seeGiftProductForm.start = 1;
        this.checkPro(null);
      },
      handleSizeChangeForGiftCoupons: function(pageSize) {
        this.giftCouponsForm.limit = pageSize;
        this.giftCouponsForm.start = 1;
        this.giftCouponsFormFind();
      },
      // 换页刷新
      handleCurrentChangeForProduct: function(pageNum) {
        this.productForm.start = pageNum;
        this.productFormFind();
      },
      handleCurrentChangeForGiftProduct: function(pageNum) {
        this.giftProductForm.start = pageNum;
        this.giftProductFormFind();
      },
      handleCurrentChangeForSeeGiftProduct(pageNum) {
        this.seeGiftProductForm.start = pageNum;
        this.checkPro(null);
      },
      handleCurrentChangeForGiftCoupons: function(pageNum) {
        this.giftCouponsForm.start = pageNum;
        this.giftCouponsFormFind();
      },

      // 商品多项目选择
      productSelectionChange(val) {
      },

      // 选择商品
      addSelectionChangeProduct(val) {
        let this_ = this;
        this_.productAddSelection = val;
      },

      //查询促销商品
      mainProductTableDataFormFind() {
        this.mainProductForm.promotionId = this.promotionId;
        let this_ = this;
        this.utils.request.promotionMerchantProductList(
          this.mainProductForm,
          function(res) {
            if (res.code == "0000") {
              this_.merchantProductTableData = res.data.rows;
              this_.merchantProductTableDataTotal = res.data.total;
            }
          }
        );
      },

      // ------------------------------------商品结束方法-------------------------------------end

      addActive() {
        this.active = parseInt(this.active)  + 1;
        this.$router.push({ query: { id: this.promotionId ,auth:0,active:this.active} })
        if (this.active > 4) {
          this.$router.push({
            path: "/pages/promotionManagement/increasePromotion"
          });
        }
      },
      back() {
        this.active = parseInt(this.active) - 1;
        this.$router.push({ query: { id: this.promotionId ,auth:0,active:this.active} })
        this.nextOrBack();
      },
      checkCountByPromotionId(){
        var _this = this;
        let callback1 = function(res) {
          if (res.code == "0000") {
            //成功后重新获取一下商家商品列表
            if(res.data > 0){
              if (_this.filters.status == 9) {
                let callback = function(res) {};
                _this.filters.status = 1;
                _this.utils.request.promotionUpdateStatus(_this.filters, callback);
              }
              _this.addActive();
            }else {
              _this.$message({ message: "换购商品未添加", type: "fail" });
            }
          } else {
            _this.$message({ message: "换购商品未添加", type: "fail" });
          }
        };
        let param = { promotionId: this.filters.id };
        marketRequest.promotionGiftItemCountByPromotionId(param, callback1);
      },
      next() {
        let _this = this;
        let callback = function(res) {
          if (res.code == "0000") {
            _this.promotionId = res.data;
            _this.filters.id = res.data;
            _this.promotion.promotionId = res.data;
            _this.mainMerchantForm.promotionId = res.data;
            _this.mainStoreMerchantForm.promotionId = res.data;
            _this.addActive();
            _this.mainMerchantFormFind();
            _this.mainStoreTableDataFormFind();
          } else {
            _this.$message({ message: "操作失败", type: "fail" });
            _this.active = 1;
          }
        };
        let callbackUpdate = function(res) {
          if (res.code == "0000") {
            _this.addActive();
            _this.mainMerchantFormFind();
            _this.mainStoreTableDataFormFind();
          } else {
            _this.$message({ message: "操作失败", type: "fail" });
            _this.active = 1;
          }
        };
        //保存活动基础配置
        if (this.active == 1) {
          this.$refs["filters"].validate(valid => {
            if (valid) {
              this.filters.startTime = this.filters.promotionStartEndTime[0];
              this.filters.endTime = this.filters.promotionStartEndTime[1];
              if(this.deptType == 3){
                this.filters.costAllocationFlag = 1;
                this.filters.storeAllocationScale = 100;
              }
              //保存会员等级 会员类型
              this.filters.memTypes = this.selectMemTypes.join(",")
              this.filters.proUserType = this.selectUserType.join(",");
              this.filters.promotionMemberGradeList = [];

              this.memberGradeList.forEach(item=>{
                this.filters.promotionMemberGradeList.push({platformId:item.businessId,levelCodeList:item.levelSelectList})
              })
              //当前登录用户身份为母平台校验所属渠道
              if (this.deptType == 0) {
                if (this.$refs.channelTree.getCheckedKeys().length <= 0) {
                  this.$message({ message: "请选择使用渠道" });
                  loading.close();
                  return false;
                } else {
                  this.filters.channelCodes = this.$refs.channelTree
                    .getCheckedKeys()
                    .join(",");
                }
              }
              if (this.promotionId == null) {
                if( new Date(this.filters.startTime) < new Date()){
                  this.$message({
                    message: "开始时间不能小于当前时间,请修改活动时间"
                  });
                  return;
                }
                this.utils.request.promotionCreate(this.filters, callback);
              } else {
                if (
                  this.filters.status == 9 &&
                  new Date(this.filters.startTime) < new Date()
                ) {
                  this.$message({
                    message: "草稿状态下开始时间不能小于当前时间,请修改活动时间"
                  });
                } else {
                  this.utils.request.promotionUpdate(
                    this.filters,
                    callbackUpdate
                  );
                }
              }
            }
          });
        }else if (this.active == 3) {//更新活动状态
          if (this.active == 3 && this.merchantProductTableData.length == 0) {
            _this.$message({ message: "商品未添加", type: "fail" });
            return;
          }
          //下一步时如选择了换购商品校验商品换购价与限购
          if(this.giftProductAddSelection && this.giftProductAddSelection.length > 0){
            for (let i = 0; i < this.giftProductAddSelection.length; i++) {
              if(!this.checkGiftProductLimits(this.giftProductAddSelection[i])){
                return;
              }
            }
          }
          this.checkCountByPromotionId();
          //this.addActive();
        }else if (this.active == 2) {
          if (
            this.storeTableData.length == 0 ||
            this.merchantTableData2.length == 0
          ) {
            //判断商家店铺
            _this.$message({ message: "商家或店铺未添加", type: "fail" });
            return;
          }
          this.getProductListV2(0, null);
          this.getMutexProductList();
          this.getPromotionStoreTableData();
          this.addActive();
        }else if (this.active == 4) {
          this.$message({ message: "操作成功", type: "success" });
          return;
        }
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      //批量选择删除商品
      handleBatchDeleteSelection(val) {
        this.batchDeleteSelection = val.map(item => {
          return item.id;
        });
      },
      //批量删除商品-todo
      delBatchMerchantProducts(ids) {
        let callback = function(res) {
          if (res.code == "0000") {
            //成功后重新获取一下商家商品列表
          } else {
            alert("删除失败");
          }
        };
        let param = { ids: ids };
        this.utils.request.promotionMerchantProductDeleteBatch(param, callback);
      },

      //删除促销商品-todo
      delMerchantProducts(id) {
        // this.$confirm("是否确认删除活动？", "提示", {
        //   type: "warning",
        //   closeOnClickModal: false,
        // })
        //   .then(() => {
            let this_ = this;
            let callback = function(res) {
              if (res.code == "0000") {
                // 成功查询本地促销商品
                this_.getProductListV2(0, null);
              } else {
                this_.getProductListV2(0, null);
                alert("删除失败");
              }
            };
            let param = {};
            param.id = id;
            marketRequest.promotionMerchantProductDelete(param, callback);
          // })
          // .catch(() => {});
      },

      repelSelectionChange(val) {
        this.repelSelection = val;
      },
      createPage() {
        this.$router.push("/CreatePromotion");
      },
      handleClick(tab, event) {
        if (tab.name == "0") {
          // 触发‘配置管理’事件
          this.first();
        } else {
          // 触发‘用户管理’事件
          this.second();
        }
      },
      first() {
        this.modalShow = 1;
      },
      second() {
        this.modalShow = 2;
      },
      //添加商品弹窗
      productSelectionModal() {
        this.productVisible = true;
      },
      showBatchSetUp() {
        if (this.search == true) {
          this.search = false;
        }
        if (this.setUp == false) {
          this.setUp = true;
        } else if (this.setUp == true) {
          this.setUp = false;
        }
      },
      showQueryCondition() {
        if (this.setUp == true) {
          this.setUp = false;
        }
        if (this.search == false) {
          this.search = true;
        } else if (this.search == true) {
          this.search = false;
        }
      },
      batchReAdd() {
        if (this.multipleSelection.length < 1) {
          this.$message({ message: "请选择要设置的商品", type: "error" });
          return false;
        }
        this.$message({ message: "操作成功", type: "success" });
      },

      importCommodityModal(val) {
        if (val === 1) {
          this.operation = true;
        } else if (val == 2) {
          this.operation = false;
        }
        this.uploadVisible = true;
      },
      // 取值
      getValue(value) {
        this.valueId = value;
      },
      handleCheckChange(data, checked, indeterminate) {
      },
      handleClose() {
      },
      nextOrBack(){
        //根据当前url中active参数判断执行第几步方法
        if (this.active){
          if (parseInt(this.active) == 2){
            this.$nextTick(() =>{
              this.mainMerchantFormFind();
              this.mainStoreTableDataFormFind();
            })
          }else if(parseInt(this.active) == 3){
            this.$nextTick(()=>{
              this.getProductListV2(0, null);
              this.getMutexProductList();
              this.getPromotionStoreTableData();
            })

          }
        }
      },

      handleCheckedAllChange(value) {
        //
        this.isIndeterminateCheck = false;

        this.allData.forEach(f => {
          f.isCheck = value;
          f.isIndeterminateCheck = false;
        });
      },
      handleCheckedChange(row, checked) {
        //
        if (row.isIndeterminateCheck) {
          row.isCheck = true;
          checked = true;
        }
        row.isIndeterminateCheck = false;

        changeChild(row, checked);
        changeParent(row, this.allData);

        this.isAllChecked = this.allData.every(e => {
          return e.isCheck;
        });

        this.isIndeterminateCheck =
          !this.isAllChecked &&
          this.allData.some(e => {
            return e.isCheck;
          });
      },

      handleCheckedAllProductChange(value) {
        //
        this.isIndeterminateProductCheck = false;

        this.allProductData.forEach(f => {
          f.isCheck = value;
          f.isIndeterminateCheck = false;
        });
      },
      handleCheckedProductChange(row, checked) {
        //
        if (row.isIndeterminateCheck) {
          row.isCheck = true;
          checked = true;
        }
        row.isIndeterminateCheck = false;

        changeChild(row, checked);
        changeParent(row, this.allProductData);

        this.isAllProductChecked = this.allProductData.every(e => {
          return e.isCheck;
        });

        this.isIndeterminateProductCheck =
          !this.isAllProductChecked &&
          this.allProductData.some(e => {
            return e.isCheck;
          });
      },

    },
    computed: {
      /* 转树形数据 */
      optionData() {
        let cloneData = JSON.parse(JSON.stringify(this.list)); // 对源数据深度克隆
        return cloneData.filter(father => {
          // 循环所有项，并添加children属性
          let branchArr = cloneData.filter(child => father.id == child.parentId); // 返回每一项的子级数组
          branchArr.length > 0 ? (father.children = branchArr) : ""; //给父级添加一个children属性，并赋值
          return father.parentId == 0; //返回第一层
        });
      }
    },
    mounted() {
      this.queryChannelListOther();
      //活动id
      //0-创建-1-编辑；
      this.auth = this.$route.query.auth;
      this.active = this.$route.query.active;
      //
      if (typeof this.$route.query.id != "undefined") {
        this.promotionId = this.$route.query.id;
        this.promotion.id = this.$route.query.id;
        this.getPromotionDetail(this.promotionId);
      }
      //根据当前url中active参数判断执行第几步方法
      this.nextOrBack();
    }
  };
</script>

<style lang="scss" scoped>
@import '../../../assets/css/public.scss';
/deep/ .is-bordered{
  padding: 12px 20px 12px 10px;
}
.mleft10 {
  margin-right: 10px;
}

.discountConditions {
  /deep/ .el-form-item__label {
    display: block;
    width: auto;
    height: 32px !important;
    line-height: 32px !important;
    float: left;
    margin-right: 10px;
  }
  /deep/ .el-input {
    width: 80%;
    float: left;
    margin-right: 10px;
  }
  span {
    float: right;
    display: block;
    width: auto;
    height: 32px;
    line-height: 32px;
  }
}
.chosenProducts {
  margin-left: 0 !important;
}
// .create_stepOne /deep/ .el-input__inner{
//   width: 210px;
// }
.discountConditions {
  /deep/ .el-input__inner {
    width: 210px !important;
  }
}
.timePick_unit {
  /deep/ .el-date-editor .el-range__icon {
    line-height: 24px;
  }
  /deep/ .el-date-editor .el-range-separator {
    line-height: 24px;
  }
}
.iconAlignment {
  /deep/ .el-input__icon {
    line-height: 32px !important;
  }
}
.errorAlignment{
  /deep/ .el-form-item__error{
    margin-top: 10px;
  }
}
.deleteIconAlignment{
  /deep/ .el-input__suffix{
    right: -20px !important;
  }
}
/deep/ .el-tabs--border-card>.el-tabs__content{
  padding: 0 !important;
}

.vt {
  /deep/ .el-form-item__content {
    vertical-align: top !important;
  }
}
.create_stepOne
.disCountSet.disCountSetTwo
.el-form-item
/deep/
.el-form-item__content
.el-input
.el-input__inner {
  width: 80px;
}
.create_stepOne
.disCountSet.disCountSetTwo
.el-form-item
/deep/
.el-form-item__content
.el-input {
  width: auto;
}
.specialTable {
  /deep/ .el-table__body tr,
  .el-table__body td {
    height: 100px !important;
  }
  /deep/ .el-table__row {
    td {
      .cell {
        text-overflow: ellipsis;
        // display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        max-height: 70px;
        overflow: visible !important;
      }
    }
  }
}
.errorInfoAlignment{
  /deep/ .el-form-item__error{
    left: 35px !important;
  }
}
.create_stepOne{
  .pdL50{
  padding-left: 44px !important;
}
}


  .flexBox{
  display: flex;
  flex-wrap: nowrap;
  align-content: flex-start;
  .child-name{
    flex-shrink: 0;
  }
  .checkboxes{
    display: flex;

  }

}
.pdl50{
  padding-left:30px
}
.pdl30{
  padding-left: 30px ;
}

.errorTipsAlignment{
  /deep/ .el-form-item__content{
    .el-form-item__error{
      position: absolute !important;
      top: -3px !important;
      left: 89px !important;
    }
  }
}

.w126{
  width: 126px;
}
.oe{
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.width100{
  width: 97px;
}
.w104{
  width: 104px;
}
.ml7{
  margin-left: 7px;
}
.pdl30{
  padding-left: 30px;
}
.pdt20{
  padding-top: 20px;
}
.labelAlignment{
  /deep/ .el-form-item__label{
    height: 33px !important;
    line-height: 33px !important;
  }
}
.w144{
  width: 144px !important;  
}
.width450{
  width: 450px !important;
  /deep/ .el-input__inner{
    width: 450px !important;
  }
}
.contentPadding{
  /deep/ .el-form-item__content{
    padding-top: 7px !important;
  }
}
</style>
